Skip to content

Instantly share code, notes, and snippets.

@Yuiki
Last active March 3, 2018 10:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Yuiki/60f8988e945064aa3568f35d4da0549b to your computer and use it in GitHub Desktop.
Save Yuiki/60f8988e945064aa3568f35d4da0549b to your computer and use it in GitHub Desktop.
授業料免除用成績平均値算出 https://gist.github.com/Yuiki/d2394e18a424f17f26b3124a3f4ff8ba の改変なのでGPAと表記していますがあしからず
import csv
import sys
argv = sys.argv
if (len(argv) != 2):
print("Usage: python3 {} gpa.csv".format(argv[0]))
quit()
total_amount = 0
total_gp = 0
gp_map = {'A+': 5, 'A': 5, 'B': 3, 'C': 2}
filename = argv[1]
with open(filename, 'r') as f:
reader = csv.reader(f)
header = next(reader)
for row in reader:
evaluation = row[6]
if evaluation in ['P', 'F', 'D']: continue
gp = gp_map.get(evaluation, 0)
amount = float(row[5])
total_amount += amount
total_gp += gp * amount
print("Your GPA is {}.".format(total_gp / total_amount))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment