Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Course:
- def __init__(self, name, units, status, score):
- self.name = name # name of the course
- self.units = units # number of units the course weighs
- self.status = status # can assume C, R or E
- self.score = score # the score achieved in the course
- @property
- def wgpa(self):
- return self.gpa * self.units
- @property
- def gpa(self):
- '''Return the gpa weight of the course.
- Computed from the score of course object.'''
- if is_between(self.score, 70, 100):
- return 7.0
- elif is_between(self.score, 65, 69):
- return 6.0
- elif is_between(self.score, 60, 64):
- return 5.0
- elif is_between(self.score, 55, 59):
- return 4.0
- elif is_between(self.score, 50, 54):
- return 3.0
- elif is_between(self.score, 45, 49):
- return 2.0
- elif is_between(self.score, 40, 44):
- return 1.0
- elif is_between(self.score, 0, 39):
- return 0.0
- else:
- raise ValueError("You entered an invalid score!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement