Created
April 7, 2017 03:04
-
-
Save benjamincohen1/7d56be3d19ac7e9500be4b99544659f3 to your computer and use it in GitHub Desktop.
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
# given a bunch of numbers, find their average | |
# 5, 15, 20, 0 | |
True False | |
mybool = (10 < 5) or (5 == 2) or (1 < 2) | |
if mybool: | |
print 'your thing was true' | |
else: | |
print 'your thing was false' | |
nums = [90, 88, 76, 100, 98, 20] | |
mytotal = 0 | |
for x in nums: | |
mytotal = mytotal + x | |
myaverage = mytotal / float(len(nums)) | |
print 'Your average is: ' + str(myaverage) | |
if (myaverage == 100): | |
print 'wow! youre perfect' | |
elif myaverage > 90: | |
print 'you got an A' | |
elif myaverage > 80: | |
print 'you got an B' | |
elif myaverage > 70: | |
print 'you got an C' | |
elif myaverage > 60: | |
print 'you got an D' | |
else: | |
print 'sorry, you got an F' | |
for var1 in [1, 2, 4, 10]: | |
for var2 in range(3): | |
print var1 | |
print 'im in the outer loop' | |
print 'im done' | |
myval = 0 | |
while myval < 20: | |
print 'currently: ' + str(myval) | |
myval = myval + input('enter a number: ') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment