Consider the following class definition: Write a property, average , for the Stu
ID: 3909520 • Letter: C
Question
Consider the following class definition:
Write a property, average, for the Student class that returns the average grade of the student assuming all the grades have equal weight (The average is the sum of all the grades divided by the total number of grades).
To get any credit on this question, you should not modify __init__ or add_grade and you should not store the average as an instance variable.
If the student does not have any grades, the average should be 0.
Once you implement the average property, you should be able to test it as follows:
alex = Student('Alex')
print(alex.average) # should print 0
zoe = Student('Zoe')
zoe.add_grade(99.5)
zoe.add_grade(89.5)
zoe.add_grade(80)
zoe.add_grade(70)
print(zoe.average) # should print 84.75
only include the property definition in your answer. Make sure you use Python built-in capabilities.
Explanation / Answer
**Comment for any further queries.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.