Dec-01-2020, 12:42 AM
Hi,
This is part of my homework. We're trying to learn/apply some concepts of OOP in this exercise.
This is what I've got so far.
x=final(my_id="001",age="33",gender="M",location="Y",math=95,science=100,english=95). I encountered a "NameError" where a variable/variables are not defined. See output below:
Best,
Art
This is part of my homework. We're trying to learn/apply some concepts of OOP in this exercise.
This is what I've got so far.
def welcome(self): print("==========WELCOME==========") class demographics: def __init__(self,my_id,age,gender,location,*args, **kwargs): #super(demographics,self).__init__(*args, **kwargs) welcome(self) print("") #print(my_id) #print(age) #print(gender) self.location = str(input("Are you In-State Y/N: ")) if self.location=='Y' or self.location=='y': print("The In-State School Fee is $560.") else: print("The Out-of-State School Fee is $913.") class grade: def __init__(self,math,science,english, *args, **kwargs): super(grade,self).__init__(*args, **kwargs) ave=(math+science+english)/3 if ave > 90: print("Your final grade is A") if ave >80 and ave <=90: print("Your final grade is B") if ave >70 and ave <=80: print("Your grade is C") if ave <=70: print("Your grade is F") class final(demographics,grade): def __init__(self,*args, **kwargs): super(final,self).__init__(*args, **kwargs) demographics(self,my_id,gender,location) print("====Student's Transcript Report====") print("Student ID: ",my_id,"","Age: ",age,"","Location (In-State Y/N): ",location) print("") print(math) print(science) print(english) print("Your average in three subjects is ",ave)However when I run my code using this example:
x=final(my_id="001",age="33",gender="M",location="Y",math=95,science=100,english=95). I encountered a "NameError" where a variable/variables are not defined. See output below:
Output:>>> x=final(my_id="001",age="33",gender="M",location="Y",math=95,science=100,english=95)
==========WELCOME==========
Are you In-State Y/N: y
The In-State School Fee is $560.
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
x=final(my_id="001",age="33",gender="M",location="Y",math=95,science=100,english=95)
File "C:\Users\among\Desktop\Assignment 3 Python\Assignment 3 Part 3.py", line 36, in __init__
demographics(self,my_id,gender,location)
NameError: name 'my_id' is not defined
>>>
Thanks very much. Appreciate any constructive feedback.Best,
Art