Question: Create a Python project manage_course. Add a Python file course.py to this project. Define a class Course in this file. This class has three publicly

Create a Python project manage_course. Add a Python file course.py to this project. Define a class Course in this file. This class has three publicly accessible instance variables to store course code, maximum class size and enrollment. Define the following methods: (a) An __init__ method that accepts course code and maximum class size as arguments. Write statements in __init__ to store them in instance variables. Also create an instance variable to store enrollment and initialize it to 0. (b) An add_student method to increase enrollment by one and display One student added if the course is not full. If the course is already full, make no change to enrollment and display Course already full. This method has no argument other than self and has no return value. (c) A drop_student method to decrease enrollment by one and display One student dropped if the course is not empty. If the course is empty, make no change to enrollment and display Course is empty. This method has no argument other than self and has no return value. The following class diagram shows the design of this class: Course +course_code: String +max_size: Integer +enrollment: Integer +create(course_code:String, max_size:Integer) +add_student() +drop_student() Add a file manage_course_main.py to this project. This is the main module. Write code to ask the user to enter course code and maximum class size of a course. Use the data provided by the user to create an instance of Course. Write a loop to manage this course. In the loop, ask the user to enter 1 for adding a student, 2 for dropping a student, 3 for displaying course info, or 0 for exit. If 1 is chosen, call the add_student method of the Course object and use a print statement to display updated enrollment. If 2 is chosen, call the drop_student method of the Course object and use a print statement to display updated enrollment. If 3 is chosen, display values stored in the Course object to show course code, maximum class size and enrollment.

Below is my code that I have written but I don't understand my mistakes. Thanks for the help.

class Course: def __init__(self): self.course_code = " "  self.max_size = 0.0 self.enrollment = 0.0 def add_student(self): self.enrollment = self.enrollment + 1 if self.enrollment > self.max_size: print('One Student Added') else: print('Course already full') def drop_student(self): self.enrollment = self.enrollment - 1 if self.enrollment != 0: print('One student dropped') else: print('Course is empty') 
from course import Course def main(): course_code = str(input('Enter course code: ')) max_size = int(input('Enter maximun class size: ')) course1 = Course() user_input = int(input('Enter 1 for add student, 2 for drop student, 3 for course info, 0 for exit: ')) while user_input != 0: if user_input == 1: course1.add_student() print('Enrollment: ', self.enrollment) elif user_input == 2: course1.drop_student() print('Enrollment: ', self.enrollment ) elif user_input == 3: print('Course Code: ', course_code) print(' Maximun class size: ', max_size) print('Enrollment: ', self.enrollment) user_input = int(input('Enter 1 for add student, 2 for drop student, 3 for course info, 0 for exit: ')) main() 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!