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
# 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 |
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
#print 10 times | |
def tentimes(): | |
print( " * " ) | |
print( " * " ) | |
print( " * " ) | |
print( " * " ) | |
print( " * " ) | |
print( " * " ) | |
print( " * " ) | |
print( " * " ) |
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
#Line of stars | |
def tentimes (): | |
print("* * * * * * * * * *") | |
tentimes() |
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
#print 10 times | |
def tentimes(): | |
print( " * " ) | |
print( " * " ) | |
print( " * " ) | |
print( " * " ) | |
print( " * " ) | |
print( " * " ) | |
print( " * " ) | |
print( " * " ) |
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
#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() |
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
#Loop program | |
def tentimes(): | |
for x in range(10): | |
print("*") | |
tentimes() |
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
# 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) |
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
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! |
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
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) |
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
# 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)) |
OlderNewer