Skip to content

Instantly share code, notes, and snippets.

@cosileone
Last active December 14, 2015 08:59
Show Gist options
  • Save cosileone/5061804 to your computer and use it in GitHub Desktop.
Save cosileone/5061804 to your computer and use it in GitHub Desktop.
Asking for grades and then averaging them.
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))
@cosileone
Copy link
Author

The float() function in grades.append(float(input)) seems redundant but too lazy to change it now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment