Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #
- # gpa.py
- # author Vaibhav Kapoor
- # CopyLeft 2012
- def main():
- f = open('gpa.txt', 'r')
- grades = ['F', 'E', 'D', 'D+', 'C', 'C+', 'B', 'B+', 'A', 'A+']
- creditTotal = 0
- points = 0
- for line in f:
- split = line.split()
- if(split[-1] in grades):
- credit = float(split[4])
- grade = float(grades.index(split[-1]))
- points += grade*credit
- creditTotal += credit
- print points / creditTotal
- f.close()
- main()
Advertisement
Add Comment
Please, Sign In to add comment