Created
December 2, 2016 04:04
-
-
Save benjamincohen1/270557c6e0bfc1e028d802f527a56bf6 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
# -*- coding: utf-8 -*- | |
""" | |
Created on Thu Dec 1 21:10:41 2016 | |
@author: ben | |
""" | |
# goal: given some numbers, find their average | |
def find_average(numbers): | |
total = 0 | |
for num in numbers: | |
total = total + num | |
# print 'Our current total is ' + str(total) | |
average = total / float(len(nums_to_sum)) | |
# print average | |
if average > 90 and len(nums_to_sum) > 5: | |
print "You got an A with a lot of tests" | |
elif average > 90: | |
print "A" | |
elif average > 80: | |
print "B" | |
elif average > 70: | |
print "C" | |
elif average > 60: | |
print "D" | |
else: | |
print "F" | |
return average | |
nums_to_sum = [100, 80, 75, 90, 120, 70, 100, 25, 68, 180] | |
nums_to_sum2 = [1, 2, 3, 4, 5] | |
print find_average(nums_to_sum) | |
print find_average(nums_to_sum2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment