Advertisement
Guest User

Untitled

a guest
Jul 28th, 2015
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. class Course:
  2.  
  3. def __init__(self, name, units, status, score):
  4. self.name = name # name of the course
  5. self.units = units # number of units the course weighs
  6. self.status = status # can assume C, R or E
  7. self.score = score # the score achieved in the course
  8.  
  9. @property
  10. def wgpa(self):
  11. return self.gpa * self.units
  12.  
  13. @property
  14. def gpa(self):
  15. '''Return the gpa weight of the course.
  16. Computed from the score of course object.'''
  17.  
  18. if is_between(self.score, 70, 100):
  19. return 7.0
  20. elif is_between(self.score, 65, 69):
  21. return 6.0
  22. elif is_between(self.score, 60, 64):
  23. return 5.0
  24. elif is_between(self.score, 55, 59):
  25. return 4.0
  26. elif is_between(self.score, 50, 54):
  27. return 3.0
  28. elif is_between(self.score, 45, 49):
  29. return 2.0
  30. elif is_between(self.score, 40, 44):
  31. return 1.0
  32. elif is_between(self.score, 0, 39):
  33. return 0.0
  34. else:
  35. raise ValueError("You entered an invalid score!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement