Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Ditto

  • Loading branch information...
commit 0f0ea5417cd0a5ea5e981276cfca8537a41c19b6 1 parent 6dad0b5
@mchow01 mchow01 authored
View
11 python/beers.py
@@ -1,11 +0,0 @@
-beers = 99
-
-while beers > 1:
- print str(beers) + " bottles of beer on the wall, " + str(beers) + " bottles of beer"
- beers = beers - 1
- if beers >= 2:
- print "Take one down and pass it around, " + str(beers) + " bottles of beer on the wall\n"
- else:
- print "Take one down and pass it around, " + str(beers) + " bottle of beer on the wall\n"
-print "1 bottle of beer on the wall, 1 bottle of beer.\nTake one down and pass it around, no more bottles of beer on the wall.\n" # Print an extra return
-print "No more bottles of beer on the wall, no more bottles of beer.\nGo to the store and buy some more, 99 bottles of beer on the wall."
View
10 python/dict.py
@@ -1,10 +0,0 @@
-bob = {'name': 'Bob Smith', 'age': 42, 'pay': 30000, 'job': 'Developer'}
-sue = {'name': 'Sue Jones', 'age': 45, 'pay': 40000, 'job': 'Musician'}
-charlie = dict(name='Charlie Weis', age=48, pay=1000000, job='Coach')
-database = {}
-database['bob'] = bob
-database['sue'] = sue
-database['charlie'] = charlie
-if __name__ == '__main__':
- for entry in database:
- print entry, ' => ', database[entry]
View
13 python/fibonacci.py
@@ -1,13 +0,0 @@
-def fibonacci (n):
- """ Returns the Fibonacci number for given integer n """
- if n == 0:
- return 0
- elif n == 1:
- return 1
- else:
- return fibonacci(n-2) + fibonacci(n-1)
-
-n = 25
-for i in range(n):
- result = fibonacci(i)
- print "The fibonacci number for ", i, " is ", result
View
6 python/file_w_test.py
@@ -1,6 +0,0 @@
-# What is the output?
-
-f = open('test.txt', 'w')
-f.write("Hi!")
-f.write("Ho!")
-f.close()
View
12 python/grades.py
@@ -1,12 +0,0 @@
-g1 = raw_input("Enter grade 1: ")
-grade1 = float(g1)
-g2 = raw_input("Enter grade 2: ")
-grade2 = float(g2)
-g3 = raw_input("Enter grade 3: ")
-grade3 = float(g3)
-g4 = raw_input("Enter grade 4: ")
-grade4 = float(g4)
-g5 = raw_input("Enter grade 5: ")
-grade5 = float(g5)
-average = (grade1 + grade2 + grade3 + grade4 + grade5) / 5
-print("The average of the 5 grades is " + str(average))
View
8 python/maintest.py
@@ -1,8 +0,0 @@
-def square(x):
- """ Self explanatory """
- return x * x
-
-if __name__ == '__main__':
- print "test: square(42) == ", square(42)
-else:
- print "Someone else is using me!"
View
1  python/maintest2.py
@@ -1 +0,0 @@
-import maintest
View
25 python/pyguess.py
@@ -1,25 +0,0 @@
-# Last updated on July 18, 2010
-from random import randint
-
-min = 1
-max = 100
-secret = randint(min, max)
-print("Welcome!")
-guess = 0
-numGuesses = 0
-while guess != secret:
- guess = 0
- while guess < min or guess > max:
- g = input("Guess the number between " + str(min) + " and " + str(max) + " (inclusive): ")
- guess = int(g)
- if guess < min or guess > max:
- print "You bozo, your guess does not count. Try again."
- numGuesses = numGuesses + 1 # Anything interesting?
- if guess == secret:
- print("You win! It took you " + str(numGuesses) + " guesses.")
- else:
- if guess > secret:
- print("Too high")
- else:
- print("Too low")
-print("Game over!")
View
24 python/time_converter.py
@@ -1,24 +0,0 @@
-def convertTimeFormat(seconds):
- ''' Assume seconds is not negative '''
- hours = seconds / 3600
- seconds = seconds % 3600
- minutes = seconds / 60
- seconds = seconds % 60
- if seconds <= 9:
- seconds = "0" + str(seconds)
- else:
- seconds = str(seconds)
- if minutes <= 9:
- minutes = "0" + str(minutes)
- else:
- minutes = str(minutes)
- if hours <= 9:
- hours = "0" + str(hours)
- else:
- hours = str(hours)
- return hours + ":" + minutes + ":" + seconds
-
-seconds = 90
-while seconds > 0:
- print convertTimeFormat(seconds)
- seconds-=1
View
4 python/urltest.py
@@ -1,4 +0,0 @@
-import urllib2
-
-page = urllib2.urlopen("http://www.cs.tufts.edu/~mchow").readlines()
-print page
Please sign in to comment.
Something went wrong with that request. Please try again.