Last active
December 14, 2015 08:59
-
-
Save cosileone/5061804 to your computer and use it in GitHub Desktop.
Asking for grades and then averaging them.
This file contains hidden or 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
done = False | |
grades = [] | |
while not done: | |
yesno = raw_input("\nDo you have a grade to enter?: ") | |
if str(yesno).lower() in ["yes", "y"]: | |
input = raw_input("\nEnter Grade: ") | |
try: | |
val = float(input) | |
except ValueError: | |
print("\nThat's not an int!") | |
else: | |
grades.append(float(input)) | |
else: | |
done = True | |
print "\nYour average is: " + str(sum(grades)/len(grades)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The float() function in grades.append(float(input)) seems redundant but too lazy to change it now.