Last active
August 29, 2015 14:24
-
-
Save letroot/6e7de9ca7f50ba2370c8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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!") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment