14.21 LAB: Course size Complete the Course class by implementing the course_size() instance method, which returns the total number of students in the course. The file main.py contains: . The main function for testing the program. • Class Course represents a course, which contains a list of Student objects as a course roster. (Type your code in here.) • Class Student represents a classroom student, which has three attributes: first name, last name, and GPA. Note: For testing purposes, different student values will be used. Ex. For the following students: Henry Bendel 3.6 Johnny Min 2.9 the output is: Course size: 2



The Algorithm of the code:-
1. Create a class Student with attributes first name, last name, and GPA.
2. Create a class Course with an attributes roster.
3. Define a constructor for the Student class with parameters first, last, and gpa.
4. Define get_gpa(), get_first(), get_last() methods for Student class.
5. Define a constructor for the Course class with a parameter roster.
6. Define add_student() and course_size() methods for Course class.
7. Define a print_roster() method for Course class which prints firstname, lastname and GPA of the student.
8. In the main function, create an instance of the Course class and add two student objects to the roster.
9. Call the print_roster() method of the Course class to print the details of the students in the roster.
10. Print the course size.
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images









