Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

GLOBAL CODE print(' Start of Department and Student class demo **************') s1 = Student('G34568', 'David Miller', status = 'sophomore', major = 'Hist', enrolled = 'y',

image text in transcribedimage text in transcribedimage text in transcribed

GLOBAL CODE print(' Start of Department and Student class demo **************')

s1 = Student('G34568', 'David Miller', status = 'sophomore', major = 'Hist', enrolled = 'y', credits = 30, qpoints = 90) s2 = Student('G21345', 'Sonia Fillmore', status = 'senior', major = 'Math', enrolled = 'y', credits = 90, qpoints = 315) s3 = Student('G42156', 'Chris Squire', status = 'sophomore', major = 'Musc', enrolled = 'y', credits = 45, qpoints = 160) s4 = Student('G10928', 'Tal wilkenfeld', status = 'junior', major = 'ARTS', enrolled = 'y', credits = 70, qpoints = 225) s5 = Student('G22157', 'Larry Graham', status = 'senior', major = 'CHHS', enrolled = 'y', credits = 105, qpoints = 290) s6 = Student('G31345', 'John Entwistle', status = 'freshman', major = 'CSci', enrolled = 'y', credits = 15, qpoints = 35) s7 = Student('G44568', 'Esperanza Spalding', status = 'junior', major = 'ENGR', enrolled = 'y', credits = 65, qpoints = 250) s8 = Student('G55345', 'Tim Bogert', status = 'sophomore', major = 'Hist', enrolled = 'y', credits = 45, qpoints = 120) s9 = Student('G66113', 'Gordon Sumner', status = 'freshman', major = 'Musc', enrolled = 'y', credits = 15, qpoints = 45) s10 = Student('G11311', 'Paul McCartney', status = 'senior', major = 'ARTS', enrolled = 'y', credits = 110, qpoints = 275) s11 = Student('G22111', 'Elizabeth Smythe', status = 'junior', major = 'ENGR', enrolled = 'y', credits = 85, qpoints = 250) s12 = Student('G31312', 'John McVie', status = 'sophomore', major = 'Hist', enrolled = 'y', credits = 45, qpoints = 120) s13 = Student('G31312', 'Nawt Enrolled', status = 'sophomore', major = 'Hist', enrolled = 'n', credits = 45, qpoints = 120) s14 = Student('G11112', 'Toolow G. Peyay', status = 'freshman', major = 'Undc', enrolled = 'y', credits = 20, qpoints = 38)

print('List of Students created: ') print('s1= ',s1) print('s2= ',s2) print('s3= ',s3) print('s4= ',s4) print('s5= ',s5) print('s6= ',s6) print('s7= ',s7) print('s8= ',s8) print('s9= ', s9) print('s10= ',s10) print('s11= ',s11) print('s12= ',s12) print('s13= ',s13) print('s14= ',s14) d1 = Department('ENGR', 'Engineering', 5, 2.75) d2 = Department('ARTS', 'Art and Architecture', 15, 2.0) d3 = Department('CHHS', 'College of Health and Human Sevrices', 10, 2.5) print(' Departments established:') print(d1) print(d2) print(d3) print(' Adding s1 - s5 to ENGR Department- print Roster follows') d1.addStudent(s1) d1.addStudent(s2) d1.addStudent(s3) d1.addStudent(s4) d1.addStudent(s5) d1.printRoster()

a, b = d1.addStudent(s6) print(' Attempting to add ', s6.name, ' to ', d1.d_code, ' - over capacity, ret values: ', a, b) d1.printRoster() print(' Adding ', s6.name, ' and ', s7.name, ' to ', d2.d_code, ', printRoster follows: ') d2.addStudent(s6) d2.addStudent(s7) d2.printRoster()

print(' Adding ', s8.name, ' and ', s9.name, ' to ', d3.d_code, ', printRoster follows: ') d3.addStudent(s8) a, b = d3.addStudent(s9) print(' Attempting to add qualified student , ', s9.name, ' to ', d3.d_code, ', CHHS, return values; ', a, b) d3.printRoster()

a, b = d3.addStudent(s14) print(' Attempting to add low GPA student ', s14.name, ', return values: ', a, b)

a, b = d2.addStudent(s13) print(' Attempting to add non-enrolled student ', s13.name, ', return values: ', a, b)

a, b = d3.addStudent(s8) print(' Attempting to add dupe student ', s8.name, ', return values: ', a, b)

print(' Adding s10 to ENGR, s11 to ARTS, s12 to CHHS, then print all 3 roster') d1.addStudent(s10) d2.addStudent(s11) d3.addStudent(s12)

d1.printRoster() d2.printRoster() d3.printRoster() print(' ***** End **********')

STUDENT CLASS USED IN Assignment 2 Could be found on the link below

https://www.chegg.com/homework-help/questions-and-answers/python-37--test-code-following-global-code-re-done-print-nstart-a2-student-class-demo-s1-s-q44362478

In this assignment you are asked to write a Python program to define a class to model some characteristics of a university Department. Specifically, the class will track students requesting to major in that particular department. Students will be represented by student objects created using the Student class developed in A2. When an attempt is made to add the student to a department's major (program), the Department class will examine the Student object data and decide whether to add them to the major. If not, the class returns a response indicating rejection with a short reason why. The Department class should have, at minimum, the following methods (you may add others): Output/returns None See Method Name Purpose Input _init_ Constructor - sets initial attribute values. d_code and d_name are positional attributes, below@@ the others are keyword with default values _str_ Displays a readable version of the Department None object addStudent Adds qualified students to the Department Student object's roster of majors. Uses isQualified object internal method to return whether qualified. is Qualified Returns whether the student is qualified for Student this major. object printRoster Prints a list of Students listed as majoring in None this department's program Department data as a printable string True (added) + 'added' False(not added)+reason True (qualified) or False (not)+reason List of students majoring in department's program @@Attribute d code d name capacity min GPA num_students univ students avgGPA roster Type str str int float int int | float List Definition Department code - 4 char str - valid: {ENGR, ARTS, CHHS Department name - str Maximum number of students allowed to major in the department Incoming student's gpa must be greater than or equal to this Total number of students listed as majors for the Department object Total number of students listed as majors in all departments | Average gpa of all students in department listed as its majors List containing student objects of those majoring in this department Attribute d code d name Type str str Initial value Constructor parm. Constructor parm. ENGR ENGR ARTS ARTS Art and Architecture CHHS CHHS College of Health and Human Services 10 capacity int 5 Set up in init , by deptartment => Set up in init , minGPA float 2.75 2.50 Attribute Type ENGR ARTS CHHS Initial value by department => num students univ students avgGPA roster into int float List 0 None - calculated Empty list List of student objects List of student objects List of student objects Below is the functionality of the required methods. Note that the * _init_ 'method is the same for all Department objects, but the individual instance attributes are given by the code that instantiates (creates) the object. All Departments ENGR-only ARTS-only CHHS-only Method Name init Constructor - initial attribute values. 1. univ_students = 0 (value shared by all objects) 2. capacity and min GPA set up according to department specifications 3. num_students = 0 4. roster = [] 5. avgGPA = not defined until d code = 'ENGR d name= 'Engineering capacity = 5 d code = d code = ARTS' 'CHHS' d_name = 'Art d name= and College of Architecture Health and capacity = 15 Human Services capacity = 10 capacity = 10 str Same method for all Departments addStudent Same method for all Departments 3. num_students = 8 4. roster = [] 5. avgGPA = not defined until students added Displays a readable version of the Department object - code, name, capacity, num students, avgGPA Adds qualified students to the department's roster (list) of majors if qualified. Uses isQualified method to return whether qualified. If qualified: adds student to Dept. roster updates avgGPA updates num_students updates univ_students resets student's major using a newly created Student method returns True + 'added If not added, returns False and a reason for not being added isQualified Same method, Same method, Same method, but uses: but uses: but uses: Internal method that returns whether the student is qualified for this major: Department must be its capacity. The student must be enrolled Uses student sameStudent method to check whether student already listed in the roster - if yes, don't add. GPA > 2.75, currently enrolled, student not already listed GPA > 2.0, student not already listed GPA > 2.5, Currently enrolled, student not already listed In this assignment you are asked to write a Python program to define a class to model some characteristics of a university Department. Specifically, the class will track students requesting to major in that particular department. Students will be represented by student objects created using the Student class developed in A2. When an attempt is made to add the student to a department's major (program), the Department class will examine the Student object data and decide whether to add them to the major. If not, the class returns a response indicating rejection with a short reason why. The Department class should have, at minimum, the following methods (you may add others): Output/returns None See Method Name Purpose Input _init_ Constructor - sets initial attribute values. d_code and d_name are positional attributes, below@@ the others are keyword with default values _str_ Displays a readable version of the Department None object addStudent Adds qualified students to the Department Student object's roster of majors. Uses isQualified object internal method to return whether qualified. is Qualified Returns whether the student is qualified for Student this major. object printRoster Prints a list of Students listed as majoring in None this department's program Department data as a printable string True (added) + 'added' False(not added)+reason True (qualified) or False (not)+reason List of students majoring in department's program @@Attribute d code d name capacity min GPA num_students univ students avgGPA roster Type str str int float int int | float List Definition Department code - 4 char str - valid: {ENGR, ARTS, CHHS Department name - str Maximum number of students allowed to major in the department Incoming student's gpa must be greater than or equal to this Total number of students listed as majors for the Department object Total number of students listed as majors in all departments | Average gpa of all students in department listed as its majors List containing student objects of those majoring in this department Attribute d code d name Type str str Initial value Constructor parm. Constructor parm. ENGR ENGR ARTS ARTS Art and Architecture CHHS CHHS College of Health and Human Services 10 capacity int 5 Set up in init , by deptartment => Set up in init , minGPA float 2.75 2.50 Attribute Type ENGR ARTS CHHS Initial value by department => num students univ students avgGPA roster into int float List 0 None - calculated Empty list List of student objects List of student objects List of student objects Below is the functionality of the required methods. Note that the * _init_ 'method is the same for all Department objects, but the individual instance attributes are given by the code that instantiates (creates) the object. All Departments ENGR-only ARTS-only CHHS-only Method Name init Constructor - initial attribute values. 1. univ_students = 0 (value shared by all objects) 2. capacity and min GPA set up according to department specifications 3. num_students = 0 4. roster = [] 5. avgGPA = not defined until d code = 'ENGR d name= 'Engineering capacity = 5 d code = d code = ARTS' 'CHHS' d_name = 'Art d name= and College of Architecture Health and capacity = 15 Human Services capacity = 10 capacity = 10 str Same method for all Departments addStudent Same method for all Departments 3. num_students = 8 4. roster = [] 5. avgGPA = not defined until students added Displays a readable version of the Department object - code, name, capacity, num students, avgGPA Adds qualified students to the department's roster (list) of majors if qualified. Uses isQualified method to return whether qualified. If qualified: adds student to Dept. roster updates avgGPA updates num_students updates univ_students resets student's major using a newly created Student method returns True + 'added If not added, returns False and a reason for not being added isQualified Same method, Same method, Same method, but uses: but uses: but uses: Internal method that returns whether the student is qualified for this major: Department must be its capacity. The student must be enrolled Uses student sameStudent method to check whether student already listed in the roster - if yes, don't add. GPA > 2.75, currently enrolled, student not already listed GPA > 2.0, student not already listed GPA > 2.5, Currently enrolled, student not already listed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

More Books

Students also viewed these Databases questions