You are viewing a single comment's thread. Return to all comments →
any advice on my code? can you make it better or even shorter?
Student class implementation with Python:
class Student(Person): def __init__(self, firstName, lastName, idNumber, scores): self.firstName = firstName self.lastName = lastName self.idNumber = idNumber self.scores = scores def calculate(self): sum = 0 for score in self.scores: sum += score avg = sum / len(self.scores) if avg <= 100 and avg >= 90: return "O" elif avg < 90 and avg >= 80: return "E" elif avg < 80 and avg >= 70: return "A" elif avg < 70 and avg >= 55: return "P" elif avg < 55 and avg >= 40: return "D" else: return "T"
Seems like cookies are disabled on this browser, please enable them to open this website
Day 12: Inheritance
You are viewing a single comment's thread. Return to all comments →
any advice on my code? can you make it better or even shorter?
Student class implementation with Python: