Created
June 17, 2017 13:23
-
-
Save Pk13055/e827acf99562d78427b2f88809a7d9e0 to your computer and use it in GitHub Desktop.
Small script to calculate cgpa
This file contains hidden or 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
#!/usr/bin/python3 | |
# enter details as follows credit mark credit mark .. | |
# ex: ./grades.py 5 A- 3 A 4 B- ... | |
from sys import argv as rd | |
grades = { 'A' : 10, 'A-' : 9, 'B' : 8, 'B-' : 7, 'C' : 6, 'C-' : 5 , 'D' : 4, 'F' : 2} | |
courses = list(map(lambda x: [float(x[0]), grades[x[-1]]], [[x, y] for x, y in zip(rd[1:], rd[1:][1:])][::2])) | |
print(sum([x[0] * x[-1] for x in courses]) / sum([x[0] for x in courses])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This script outputs your CGPA to
stdout
:chmod 755 grades.py
./grades.py <credit> <grade> <credit> <grade> ...