Skip to content

Instantly share code, notes, and snippets.

@shawa
Created May 10, 2017 19:42
Show Gist options
  • Save shawa/4cb9ee51fa4084cdca85e2a619f26bff to your computer and use it in GitHub Desktop.
Save shawa/4cb9ee51fa4084cdca85e2a619f26bff to your computer and use it in GitHub Desktop.
Maki will go to college we pray
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