Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import csv
- def main():
- semester = []
- sem_index = -1
- grade , credit = 0,0
- grade_to_num = { 'A':4, 'B+':3.5 , 'B':3 , 'C+':2.5, 'C':2, 'D+':1.5, 'D':1, 'F':0}
- with open('csvgrade.csv', 'r') as f:
- reader = csv.reader(f)
- for row in reader:
- if row[1] != '':
- grade += int(row[1]) * grade_to_num[row[2]]
- credit += int(row[1])
- semester[sem_index] = round(grade/credit,2)
- else:
- semester.append(0)
- grade = 0
- credit = 0
- sem_index += 1
- print("GPA > ",semester)
- print("GPAX > ",sum(semester)/len(semester))
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement