Skip to content

Instantly share code, notes, and snippets.

@cwake
cwake / timeconversion.py
Last active August 29, 2015 14:13
Chloe's Time Conversion Program
# Chloe's time conversion. Converts seconds to minutes and hours
print("Chloe's time conversion program: converts seconds into minutes and hours.")
seconds = int(input("Enter any number of seconds to convert to both minutes and hours: "))
minutes = seconds / 60 #60 seconds in a minute
hours = minutes / 60 # 60 minutes in a hour
print(str(seconds) + ' seconds is ' + str(minutes) + 'minutes.') # prints minutes conversion
print(str(seconds) + ' seconds is ' + str(hours) + 'hours.') # prints hours
@cwake
cwake / tentimes.py
Created January 14, 2015 05:06
Times 10
#print 10 times
def tentimes():
print( " * " )
print( " * " )
print( " * " )
print( " * " )
print( " * " )
print( " * " )
print( " * " )
print( " * " )
@cwake
cwake / Linestars.py
Created January 14, 2015 05:19
Prints 10 stars
#Line of stars
def tentimes ():
print("* * * * * * * * * *")
tentimes()
@cwake
cwake / 10times.py
Created January 14, 2015 05:23
Prints stars 10 times, different lines
#print 10 times
def tentimes():
print( " * " )
print( " * " )
print( " * " )
print( " * " )
print( " * " )
print( " * " )
print( " * " )
print( " * " )
@cwake
cwake / 1to100.py
Created January 24, 2015 02:57
Adds all numbers 1 to 100
#1to100
def onetohundred():
sum = 0 ;
for i in range( 1 , 100):
sum= sum + i;
print("Print the sum of all numbers 1 to 100:",sum);
onetohundred()
@cwake
cwake / Loopprogram.py
Created January 24, 2015 03:01
Loops stars 10 times
#Loop program
def tentimes():
for x in range(10):
print("*")
tentimes()
@cwake
cwake / graphicshomework.py
Created February 1, 2015 07:02
Shapes homework
# graphicshomework.py
# Draws one shape (a circle), a rectangle for practice, a polygon and some text, as required. Also adds some color!
# By: Chloe Wake
# import the right module
from graphics import *
# create the window
win = GraphWin('Shapes', 400, 400)
@cwake
cwake / week5practice.py
Last active August 29, 2015 14:15
Week 5 Practice Exercises
s1 = "spam"
s2 = "ni!"
#test these
print("The Knights who say, " + s2) # The Knights who say, ni!
print(3 * s1 + 2 * s2) # spamspamspamni!ni!
print(s1[1]) # p
print(s1[1:3]) # pa
print(s1[2] + s2[:2]) # ani
print(s1 + s2[-1]) # spam!
@cwake
cwake / lists.py
Last active August 29, 2015 14:15
ints = range(5)
odds = range(1, 10, 2)
tens = range(10, 51, 10)
def milestokilometers(numbers):
for m in numbers:
print(round(m * 1.609344, 3))
milestokilometers(ints)
milestokilometers(odds)
# Convert miles into kilometers
#using ints
ints = (5)
odds = (1,10,2)
tens = (10,51,10)
def milestokilometers (numbers)
for m in numbers:
print (round (m * 1.609344, 3))