Created
July 8, 2015 16:04
-
-
Save letroot/98ebccd1bcfae65f8b08 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): | |
# global get_gpa | |
self.name = name | |
self.units = units | |
self.status = status | |
self.score = score | |
self.gpa = self.get_gpa() | |
self.wgpa = self.gpa * self.units | |
def is_between(score, lower, upper): | |
return score >= lower and score <= upper | |
def get_gpa(self): | |
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!") | |
# def __str__(): | |
course1 = Course("intro to computation", 3, 'compulsory', 45) | |
# print course1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment