Advertisement
Guest User

Untitled

a guest
Dec 5th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.03 KB | None | 0 0
  1. ##################################################################################
  2. def readFile(NameList, CourseworkList, PrelimList, percentage_mark):
  3. #opening the file with the data
  4. calculation = 0
  5. with open ('SDD Unit Assess P3 Class Marks.csv') as csvfile:
  6. GRADE_CSV = csv.reader(csvfile, delimiter=',')
  7. for row in GRADE_CSV:
  8. name = row[0]
  9. coursework_mark = row[1]
  10. prelim_mark = row[2]
  11.  
  12. NameList.append(name)
  13. CourseworkList.append(int(coursework_mark))
  14. PrelimList.append(int(prelim_mark))
  15.  
  16. #calculating the % mark for the pupil
  17. calculation = (100/150) * (int(coursework_mark)) + (int(prelim_mark))
  18. percentage_mark.append(calculation)
  19. csvfile.close()
  20. calculatepercentage(percentage_mark, grade)
  21.  
  22. ##################################################################################
  23. def calculatepercentage(percentage_mark, grade):
  24. #if statement to find out grade for pupil
  25. for index in range (0,12):
  26. if percentage_mark[index] < 45.00:
  27. grade.append("no grade")
  28. elif percentage_mark[index] >=45.00 and percentage_mark[index] <= 49.00:
  29. grade.append("D")
  30. elif percentage_mark[index] >=50.00 and percentage_mark[index] <= 59.00:
  31. grade.append("C")
  32. elif percentage_mark[index] >=60.00 and percentage_mark[index] <= 69.00:
  33. grade.append("B")
  34. elif percentage_mark[index] >= 70.00:
  35. grade.append("A")
  36.  
  37. #display data to user
  38. print(NameList[index], "you got" , round(percentage_mark[index],2), "% and your grade was", grade[index])
  39. ##################################################################################
  40. #MAIN PROGRAM
  41. #importing file with the data
  42. import csv
  43.  
  44. #declaring variables
  45. name = ""
  46. coursework_mark = 0
  47. prelim_mark = 0
  48. NameList = []
  49. CourseworkList = []
  50. PrelimList = []
  51. grade = []
  52. percentage_mark = []
  53.  
  54. readFile(NameList, CourseworkList, PrelimList, percentage_mark)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement