Question
hi i need someone to tell me why my code is compiling and not printing in shell here is the decription of the problem: Write
hi i need someone to tell me why my code is compiling and not printing in shell
here is the decription of the problem:
Write a class named Student (filename student.py) that holds the following data about a student in attributes:
Name
ID
Classification
Major
GPA
Once you have written the class, write a program (filename hw1.py) that creates four Student objects and then use a set function to change the name of one of your objects. Your program should display the data for each student on the screen.
Properly and adequately comment your code.
EXTRA CREDIT (5pts): Allow your class to accept an empty constructor with default value for your attribute name set to .
// studentinfo.py
# define class class Student: #"Here i am geting basic information about a student" def __init__(self,name = None,ID = None,classification=None,major= None,gpa=None):#constructor for name class if name is None: self.__name = '' else: self.__name = name if ID is None: self.__ID = 0 else: self.__ID = ID if classification is None: self.__classification = '' else: self.__classification = classification if major is None: self.__major = '' else: self.__major = major if gpa is None: self.__gpa = 0 else: self.__gpa = gpa #setter functions def set_name(self,name): #sets name of person self.__name = name def set_Id(self,ID): #sets ID of student self.__ID = ID def set_classification(self,classification):#sets classification of student self.__classification = classification def set_major(self,major): self.__major = major def set_gpa(self,gpa): self.__gpa = gpa #getter functions def get_name(self): return self.__name def get_ID(self): return self.__ID def get_classification(self): return self.__classification def get_major(self): return self.__major def get_gpa(self): return self.__gpa // if i dont use arguments for my get functions it says i need them, it also says my constructor cannot construct over 5 things, but i have 6.
// mainstudent.py.
import studentinfo
def main(): ## studentA = jada.Student('Jayla',900745231,'junior','computer science',3.3) ## print(studentA.get_name())
## StudentB = studentinfo.Student() # print(StudentB.get_name()) # print(StudentB.getID()) # StudentB.set_name('Karen') # print(StudentB.get_name()) # main() ob1=studentinfo.Student()
ob1.set_name('Joey')
ob1.set_ID('123456')
ob1.set_classification('Boy')
ob1.set_major('Computer Science')
ob1.set_gpa(7.86)
print(ob1.get_name())
print(ob1.get_ID())
print(ob1.get_classification())
print(ob1.get_major())
print(ob1.get_gpa()) ob2 = studentinfo.Student()
ob2.set_name('Chandler')
ob2.set_ID('123457')
ob2.set_classification('Boy')
ob2.set_major('Computer Science')
ob2.set_gpa(7.86)
print()
print(ob2.get_name()) print(ob2.get_ID())
print(ob2.get_classification())
print(ob2.get_major())
print(ob2.get_gpa())
ob3 = studentinfo.Student()
ob3.set_name('Ross')
ob3.set_ID('123458')
ob3.set_classification('Boy')
ob3.set_major('Computer Science')
ob3.set_gpa(7.86)
print()
print(ob3.get_name())
print(ob3.get_ID()) print(ob3.get_classification())
print(ob3.get_major())
print(ob3.get_gpa())
ob4 = studentinfo.Student()
ob4.set_name('Mathew')
ob4.set_ID('123459')
ob4.set_classification('Boy')
ob4.set_major('Computer Science')
ob4.set_gpa(7.86)
print()
print(ob4.get_name())
print(ob4.get_ID())
print(ob4.get_classification())
print(ob4.get_major())
print(ob4.get_gpa())
main()
//
Step 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