Python Forum
Generating a student's transcript [OOP concept]
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Generating a student's transcript [OOP concept]
#1
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.
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
Reply


Messages In This Thread
Generating a student's transcript [OOP concept] - by aongkeko - Dec-01-2020, 12:42 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Student project - alert action when X happens Y amt of times, how? unknown00 2 1,800 Aug-25-2021, 08:07 PM
Last Post: namarang
  Student grader and sorter for assignment RazeAD 7 3,181 Feb-11-2021, 06:29 AM
Last Post: RazeAD
  Create code for input names and score for 15 student Davin 2 2,079 Sep-21-2020, 08:49 AM
Last Post: DeaD_EyE
  New Python Student = Does this code look right? musicjoeyoung 6 3,436 May-07-2020, 02:39 PM
Last Post: musicjoeyoung
  Understanding the "self" concept peace 7 3,363 Feb-10-2020, 08:21 PM
Last Post: nilamo
  Help learning a concept Ccjake 2 2,336 Jan-22-2019, 01:35 AM
Last Post: Ccjake
  Student grade program help debug ccm1776 3 5,169 Nov-14-2018, 02:41 AM
Last Post: stullis

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020