Question: Using python define a student class that models college students with these instance attributes: (1) full name of student (2) gender (female, male, non-binary) (3)
Using python define a student class that models college students with these instance attributes: (1) full name of student (2) gender (female, male, non-binary) (3) major (4) units completed (5) year (1 for freshmen, 2 for sophmore, etc).
Define a constructor that must be called by sending values for name and gender and optionally can provide values for major and year. Use the default values of "undeclared" for major and 1 for year.
Define these next instance methods: (1) a mutator method with a parameter for a new major that sets the major of the student object to a new major (2) a mutator method with a list parameter for additional courses the student has completed. The method changes the courses completed to include all the courses listed in the parameter. Avoid storing duplicates. You need to assume that each course completed is 3 units and update the units completed appropriately. For example if the method is called with a list naming 3 courses then the units completed must increase by 9 units. You also need to update the year instance attribute to reflect the following: a student is in the first year if they've completed less than 30 units, a second year student is one who has completed between 30 and 59 units, a third year student is one who has completed between 60 and 89 units, and a fourth year student has completed at least 90 units. (3) __str__ : this method needs to override the default way in which an object is printed. Define the method to print the full name, major, units comoleted, and the year the student is in. (4) define a method to print everything that the previous method prints
Define a main script where you create five instances of the student class.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
