Created
May 10, 2017 19:42
-
-
Save shawa/4cb9ee51fa4084cdca85e2a619f26bff to your computer and use it in GitHub Desktop.
Maki will go to college we pray
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
import sys | |
infile = sys.argv[1] | |
with open(infile, 'r') as f: | |
triples = (line.split(',') for line in f) | |
GRADES = [(int(t[1]), int(t[2])) for t in triples] | |
total_credits = sum(credits for (credits, _) in GRADES) | |
if total_credits != 240: | |
print(r"/!\ YOU DIDN'T ENTER 240 worth of credits!") | |
gpa = sum(score * weight for (weight, score) in GRADES)/total_credits | |
print(gpa) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment