Advertisement
Guest User

Untitled

a guest
Sep 20th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. def cgpaCalculator():
  2. #This is the total Score Obtainable based on the Number Of Courses Offerred
  3. TotalScoreOfferable = 0
  4. #This is the score obtained by the person which is intially zero
  5. obtainedGrade = 0
  6.  
  7. # The user Enters the Number of Courses he Offered
  8. numberOfCourses = int(input("Please Enter the number of Courses you Offered: "))
  9. print ("**********************************************************************************************************************************")
  10. # this creates a for loop to collect all Courses offered
  11. for x in range(numberOfCourses):
  12. # This takes in the name of the course
  13. Course1 = input("Enter The Course code of the course you took:")
  14. # THis takes in the number of unit of the course
  15. unit = int(input ("How many Unit is the Course you took: "))
  16. #This takes in the person score in the course
  17. score = int(input("Please Enter your Score:"))
  18. print ("**********************************************************************************************************************************")
  19.  
  20. #This increament the totalScore obtainable based on the unit of the course
  21. TotalScoreOfferable += unit* 5
  22.  
  23.  
  24. # these are cases for grade (70-100 = 5 points , 60-70 = 4 points , 50-60 = 3 points ,50-45 = 2 points , 45-40 = 1 point , lesser than 40 = 0 points )
  25. if (score >= 70):
  26. grade = 5
  27. elif(score < 70 and score >= 60):
  28. grade = 4
  29. elif(score < 60 and score >= 50 ):
  30. grade = 3
  31. elif(score < 50 and score >=45):
  32. grade = 2
  33. elif (score < 45 and score>=40):
  34. grade = 1
  35. else :
  36. grade = 0
  37.  
  38.  
  39. obtainedGrade += unit*grade
  40.  
  41. Cgpa =float((obtainedGrade / TotalScoreOfferable) * 5)
  42. print("THANKS FOR ALL YOUR INPUT YOUR CGPA IS : " + str(Cgpa))
  43.  
  44.  
  45. cgpaCalculator()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement