Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ##################################################################################
- def readFile(NameList, CourseworkList, PrelimList, percentage_mark):
- #opening the file with the data
- calculation = 0
- with open ('SDD Unit Assess P3 Class Marks.csv') as csvfile:
- GRADE_CSV = csv.reader(csvfile, delimiter=',')
- for row in GRADE_CSV:
- name = row[0]
- coursework_mark = row[1]
- prelim_mark = row[2]
- NameList.append(name)
- CourseworkList.append(int(coursework_mark))
- PrelimList.append(int(prelim_mark))
- #calculating the % mark for the pupil
- calculation = (100/150) * (int(coursework_mark)) + (int(prelim_mark))
- percentage_mark.append(calculation)
- csvfile.close()
- calculatepercentage(percentage_mark, grade)
- ##################################################################################
- def calculatepercentage(percentage_mark, grade):
- #if statement to find out grade for pupil
- for index in range (0,12):
- if percentage_mark[index] < 45.00:
- grade.append("no grade")
- elif percentage_mark[index] >=45.00 and percentage_mark[index] <= 49.00:
- grade.append("D")
- elif percentage_mark[index] >=50.00 and percentage_mark[index] <= 59.00:
- grade.append("C")
- elif percentage_mark[index] >=60.00 and percentage_mark[index] <= 69.00:
- grade.append("B")
- elif percentage_mark[index] >= 70.00:
- grade.append("A")
- #display data to user
- print(NameList[index], "you got" , round(percentage_mark[index],2), "% and your grade was", grade[index])
- ##################################################################################
- #MAIN PROGRAM
- #importing file with the data
- import csv
- #declaring variables
- name = ""
- coursework_mark = 0
- prelim_mark = 0
- NameList = []
- CourseworkList = []
- PrelimList = []
- grade = []
- percentage_mark = []
- readFile(NameList, CourseworkList, PrelimList, percentage_mark)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement