Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

hi i need someone to tell me why my code is not compiling and printing here is t

ID: 2246640 • Letter: H

Question

hi i need someone to tell me why my code is not compiling and printing

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 ‘ ‘ .


//class saved as 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 classifiation 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,name):
return self.__name
def get_ID(self,ID):
return self.__ID
def get_classification(self,classification):
return self.__classification
def get_major(self,major):
return self.__major
def get_gpa(self,gpa):
return self.__gpa
  
  
  

//

//main saved as 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())
  
  

Explanation / Answer

I have highlighted the changes in comments in Capital letters.

Please check for the indentation as the editor didn't allow to do so.

---------- studentinfo.py file ---------

# define class

class Student:

#"Here i am geting basic information about a student"

  

#constructor for name class

def __init__(self,name = None,ID = None,classification=None,major= None,gpa=None):

if name is None:

self.__name = ''

else:

self.__name = name

  

if ID is None:

self.__ID = 0

else:

self.__ID = ID

  

# YOU HAD WRITTEN classifiation INSTEAD OF classification

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

# YOU DONT NEED AN ARGUMENT HERE IN THE 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

---------- mainstudent.py file ---------

import studentinfo

def 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())

# YOU DIDN'T CALL THE MAIN FUNCTION

main()