Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python please! 2 9 . 1 7 LAB: Count probations Students are put on probation if their GPA is below 2 . 0 . Complete

Python please! 29.17 LAB: Count probations
Students are put on probation if their GPA is below 2.0. Complete the Course class by implementing the count_probation() instance method, which returns the number of students with a GPA below 2.0.
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.
Hint: Refer to the Student class to explore the available instance methods that can be used for implementing the count_probation() method.
Note: For testing purposes, different student values will be used.
Ex. For the following students:
Henry Cabot 3.2
Brenda Stern 1.1
Lynda Robison 2.4
Jane Flynn 1.8
the output is:
Probation count: 2
class Student:
def __init__(self, first, last, gpa):
self.first = first # first name
self.last = last # last name
self.gpa = gpa # grade point average
def get_gpa(self):
return self.gpa
def get_last(self):
return self.last
class Course:
def __init__(self):
self.roster =[] # list of Student objects
def add_student(self, student):
self.roster.append(student)
def course_size(self):
return len(self.roster)
# Type your code here
if __name__=="__main__":
course = Course()
course.add_student(Student('Henry', 'Cabot', 3.2))
course.add_student(Student('Brenda', 'Stern', 1.1))
course.add_student(Student('Lynda', 'Robison', 2.4))
course.add_student(Student('Jane','Flynn',1.8))
prob_count = course.count_probation()
print('Probation count:', prob_count)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions