Question
For Python 3.7+. TEST THE CODE WITH THE FOLLOWING GLOBAL CODE AFTER YOU'RE DONE: print(' Start of A2 Student class demo ') s1 = Student('David
For Python 3.7+.
TEST THE CODE WITH THE FOLLOWING GLOBAL CODE AFTER YOU'RE DONE:
print(' Start of A2 Student class demo ')
s1 = Student('David Miller', major = 'Hist',enrolled = 'y', credits = 0, qpoints = 0) s2 = Student('Sonia Fillmore', major = 'Math',enrolled = 'y', credits = 90, qpoints = 315) s3 = Student('A. Einstein', major = 'Phys',enrolled = 'y', credits = 0, qpoints = 0) s4 = Student('W. A. Mozart', major = 'Mus',enrolled = 'n', credits = 29, qpoints = 105) s5 = Student('Sonia Fillmore', major = 'CSci',enrolled = 'y', credits = 60, qpoints = 130) s5.g_num = s2.g_num s6 = Student('Pierre Renoir', major = 'Art',enrolled = 'y', credits = 120, qpoints = 315) print('s1 = ', s1) print('s2 = ', s2) print('s3 = ', s3) print('s4 = ', s4) print('s5 = ', s5) print('s6 = ', s6) print(' Total number of students: ', Student.totalEnrollment) print('The gpa of ', s1.name, ' is ', s2.gpa()) print('Class standing of ', s4.name, ' is ', s4.status()) print('Class standing of ', s2.name, ' is ', s2.status()) if s1.sameStudent(s2): print (s1.name, ' and ', s2.name, ' are the same student') else: print (s1.name, ' and ', s2.name, ' are not the same student') if s2.sameStudent(s5): print (s2.name, ' and ', s5.name, ' are the same student') else: print (s2.name, ' and ', s5.name, ' are not the same student') if s1.isEnrolled(): print (s1.name, ' is currently enrolled') else: print (s1.name, ' is not currently enrolled') if s4.isEnrolled(): print (s4.name, ' is currently enrolled') else: print (s4.name, ' is not currently enrolled') print(' End of A2 Student class demo')
In this assignment you are asked to write a Python program to define a class to model the characteristics of a university student. The class is part of a slightly larger program that includes code to use the class to create some student objects and test its methods. The name of the class is 'Student' and includes the following methods and attributes: Input/parm See below@ Output/returns None None Student data as a printable string gpa (float) gpa None Method Name Purpose _init__. Constructor - sets initial attribute values. name is a positional attribute, the others are keyword with default values. g num is generated as described in the next table. str_ Displays a readable version of the Student object Calculates and returns the student's gpa. gpa =qpoints / credits isEnrolled Returns whether the student is currently enrolled. (y' = True, 'n' = False) status Computes class status based on # of credits completed (90+ = 'Senior', 60+ = 'Junior', 30+ = 'Sophomore', + totalEnrollment at the time the student object was created - assigned by the class Student nameStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started