← Back to Classes
Question 508
Class Average Of A Course
Class Average Of A Course
The Student class is given. Write the whole Course class: a course is not a kind of student, it HAS students, so the constructor takes a code string and creates an empty list attribute students; enrol(student) appends a Student; class_average() loops over the enrolled students, adds up each one's average() and returns that total divided by how many students there are. Do NOT write a main block or any top-level test code; the tests construct the class. Input: one line of grades separated by spaces for a third student, which the tests read as floats and enrol after two fixed students; the tests then print how many students are enrolled and the class average.
Expected Output:
3 85.0
= newline. The output ends with a newline — print one after the last line.
Hints3 available
Sign in to use hintsTopics:
Classes
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Ctrl+Space to expand shortcuts (pr, inp, def)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.