This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#quadratic formula | |
def quad(a,b,c): | |
root1 = (-b+((b**2)-4*a*c)**(.5))/(2*a) | |
root2 = (-b-((b**2)-4*a*c)**(.5))/(2*a) | |
print(root1) | |
print(root2) | |
return a,b,c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Date and time program | |
#codecademy | |
from datetime import datetime | |
now = datetime.now() | |
print str(now.month) +"/"+ str(now.day) +"/"+ str(now.year) +" "+ str(now.hour) +":"+ str(now.minute) +":"+ str(now.second) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Pig Latin translator | |
#codecademy | |
pyg = 'ay' | |
original = raw_input('Enter a word:') | |
if len(original) > 0 and original.isalpha(): | |
word = original.lower() | |
first = word[0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# For this exercise we assume to draw random points inside the square on the [-1,1] unit, | |
# and thus the value of Pi = 4(# random pts insid cirlce / # random pts in square) | |
sim.pi <- function(iterations = 1000) { | |
# Generate two vectors for random points in unit circle | |
x.pos <- runif(iterations, min=-1, max=1) | |
y.pos <- runif(iterations, min=-1, max=1) | |
# Test if draws are inside the unit circle | |
draw.pos <- ifelse(x.pos^2 + y.pos^2 <= 1, TRUE, FALSE) | |
draws.in <- length(which(draw.pos == TRUE)) | |
# Estimate Pi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from random import random | |
from math import pow | |
simulations = 5000 | |
hits = 0.0 | |
for x in range(simulations): | |
x = random() | |
y = random() | |
distance = pow(x,2) + pow(y,2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import webbrowser | |
import sys | |
print ("Do you need to study?") | |
print("") | |
question = input() | |
if question == "no": | |
webbrowser.open("http://facebook.com/") | |
webbrowser.open("https://mail.google.com/mail/u/0/#inbox") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import smtplib | |
from email.mime.text import MIMEText | |
# Message to be sent | |
message = MIMEText("Hello, texting!") | |
# Sending email username/password and receiving phone number | |
email_username = "email" | |
email_password = "password" | |
phone_number = "516#######" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
x = int(input("enter an integer: ")) | |
ans = 0 | |
while ans*ans*ans < abs(x): | |
ans = ans +1 | |
print ("current Guess =", ans) | |
print ("last guess = ", ans) | |
print ("ans*ans*ans = ", ans*ans*ans) | |
if ans*ans*ans == abs(x): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for i in range(1,101): | |
s = str(i) | |
if i % 3 == 0 or i % 5 == 0: | |
s = " " | |
if i % 3 == 0: | |
s = s + "Fizz" | |
if i % 5 == 0: | |
s = s + "Buzz" | |
print (s) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* The template for displaying image attachments | |
* | |
* | |
* @package i_spirit | |
* @since i-spirit 1.0 | |
*/ | |
get_header(); ?> |
OlderNewer