class Student: def __init__(self, first_name, last_name, grades=[]): self.first_name = first_name self.last_name = last_name self.grades = grades @property def full_name(self): return f'{self.first_name} {self.last_name}' @property def email(self): return f'{self.first_name}{self.last_name[0]}@codewars.com' @property def grade_average(self): return sum(self.grades) / len(self.grades) def assess(self): grades = [('A', 90), ('B', 80), ('C', 70), ('D', 65)] avg = self.grade_average for grade in grades: if avg >= grade[1]: return grade[0] return 'F'
- class Student:
def __init__(self, first_name, last_name, grades=None):- def __init__(self, first_name, last_name, grades=[]):
- self.first_name = first_name
- self.last_name = last_name
self.grades = [] if grades is None else grades- self.grades = grades
- @property
- def full_name(self):
- return f'{self.first_name} {self.last_name}'
- @property
- def email(self):
- return f'{self.first_name}{self.last_name[0]}@codewars.com'
- @property
- def grade_average(self):
- return sum(self.grades) / len(self.grades)
- def assess(self):
if self.grade_average >= 90:return "A"if self.grade_average >= 80:return "B"if self.grade_average >= 70:return "C"if self.grade_average >= 65:return "D"return "F"- grades = [('A', 90), ('B', 80), ('C', 70), ('D', 65)]
- avg = self.grade_average
- for grade in grades:
- if avg >= grade[1]:
- return grade[0]
- return 'F'