2 class parent class
class person:
def __init__(self,name,age):
self.name=name
self.age=age
class student(person):
def __init__(self,name,age,roll):
super().__init__(name,age)
self.roll=roll
def display(self):
print("student",self.name)
print("student",self.age)
print("student",self.roll)
class employee(person):
def __init__(self,name,age,roll):
super().__init__(name,age)
self.id1=id1
def display(self):
print("employee",self.name)
print("employee",self.age)
print("employee",self.id1)
n=int(input())
for i in range(n):
t=input()
if t=="student":
name=input()
age=int(input())
roll=int(input())
s=student(name,age,roll)
elif t=="employee":
name=input()
age=int(input())
id1=int(input())
e=employee(name,age,id1)
s.display()
e.display()
Comments