Posts

Showing posts from October, 2018

Search Results

Spooky Halloween Code

Image
Spooky Halloween Code using HTML5  CSS and JavaScript


<!DOCTYPE html> <html>     <head>         <title>Happy Halloween</title>         <style>             body {     background-image:url("https://media.giphy.com/media/1V17m8MgM0fEk/giphy.gif"); } h2{     color:orange; } #a{ position:absolute ; top:580px; left:180px; font-size:24px; } #b{ position:absolute ; top:400px; left:300px; font-size:24px;

} #c{ position:absolute ; top:350px; left:200px; font-size:24px;

} #d{ position:absolute ; top:480px; left:80px; font-size:24px;

} #e{ position:absolute ; top:640px; left:150px; font-size:24px;

} #f{ position:absolute ; top:450px; left:310px; font-size:24px;
} #g{ position:absolute ; top:610px; left:30px; font-size:24px;

} #h{ position:absolute ; top:520px; left:130px; font-size:24px;

} #i{ position:absolute ; top:690px; left:270px; font-size:24px;

} #j{ position:absolute ; top:440px; left:280px; font-size:16px;

}
        </style>     </h…

Scientific Notation using Python

Image
Scientific Notation using Python
*Featured Code Submitted and Created by VENOM666
Python
# 365 DAYS OF CODE: DAY 2: SCIENTIFIC NOTATION (ASSIGNMENT) # https://www.sololearn.com/learn/10004/?ref=app # by: VENOM666
from math import floor
def scientific_notation(num):     if num > 1: # accepts only arguments that is not a float less than 1, e.g 0.00082         exponent = 0         while floor(num) > 10: #leaves one digit at the ones place             num = num / 10 #shift decimal place to the right             exponent += 1
        print(('{} x 10^{}').format(num, exponent))
    else:         exponent = 0         while floor(num) == 0: #ones place must have value greater than 0             num = num * 10 #shift decimal place to the left             exponent += 1         print(('{} x 10^-{}').format(round(num, 4), exponent)) scientific_notation(12351283517280561) scientific_notation(0.000000065)


Click here to run this Code



Share with Friends

More Free Code Examples:
Py…

Machine Learning Logistic Regression

Image
Python Machine Learning Logistic Regression

*Featured Code submitted and Created by Kuba Siekierzynski
Python
""" Machine Learning with Python Logistic regression (revisited)
Coded by Kuba Siekierzynski (c) 2018
The code is the second of the series inspired by the awesome Andrew Ng's video course on machine learning: http://www.coursera.org/learn/machine-learning
This code shows an implementation of logistic regression, the initial machine learning algorithm to predict discrete values. """
# suppress the warnings when logarithm calculates infinity import warnings warnings.simplefilter("ignore", RuntimeWarning)
# The problem to be solved: # We have forty samples of fish, that we have measured on two dimensions - weight and length. Based on the measurements, half of them was categorized as 'good' and half as 'bad'. We now want to work out a model able to predict, which category will a newly caught fish be, given its measuremen…

NASA API with Python

Image
API Interaction with NASA using Python
*Featured Code Submitted and Created by VENOM666

#365 DAYS OF CODE: DAY 3: NASA OPEN API INTERACTION - 1ST ATTEMPT # by: VENOM666
# Developer's Note: I don't have a grasp on how API interaction works, please help me
#    What does this do? #        Shows the data for the Astronomical Picture of the Day (APOD)
from urllib.request import urlopen as url_open import json #javascript object notation #from PIL import Image #Python Imaging Library
url = 'https://api.nasa.gov/planetary/apod?' # I don't get how url queries work, someone help API_KEY = 'api_key=dWpZtxYFFudFeJi4KnQmoDXZz6y8rf7pPus6yoqu' #own API key, please register for your own at NASA Open APIs
decoded_string = url_open(url + API_KEY).read().decode('utf-8') #url_open().read() returns a string with b prepended, which needs to be decoded first with decode('utf-8') before it can be transformed into json format decoded_json = json.loads(decoded_stri…

Python Machine Learning Linear Regression

Image
Machine Learning Linear Regression with Python
This is an amazing code example of Machine Learning with a real world application.
*Featured Code submitted and Created by Kuba Siekierzynski
Python


""" Machine Learning with Python Linear regression
Coded by Kuba Siekierzynski (c) 2017
The code is the first of the series inspired by the awesome Andrew Ng's video course on machine learning: http://www.coursera.org/learn/machine-learning This code shows an implementation of linear regression, the initial machine learning algorithm to predict continuous values. """
# The problem to be solved: # We have trucks located in different cities and each truck brings a profit or loss. We have the historical data and determined that the profit depends on the city's population. We want to find this relation.
import numpy as np print('Welcome to Machine Learning with Python!') print('Lesson 1: Linear regression') print('\n'+40*'=')