Advertisements
Advertisements
प्रश्न
Find the output of the following code and write the type of inheritance:
class person(object):
def __init__(self,name,age):
self.name=name
self.age=age
def display1(self):
print "Name :",self.name
print "Age :",self.age
class student(person):
def __init__(self,name,age,rollno,marks):
super(student,self).__init__(name,age)
self.rollno=rollno
self.marks=marks
def display(self):
self.display1()
print " Roll No:",self.rollno
print " Marks :",self.marks
class Gstudent(student):
def __init__(self,name,age,rollno,marks,stream):
super(Gstudent,self).__init__(name,age,rollno,marks)
self.stream=stream
def display2(self):
self.display()
print " stream:",self.stream
p=Gstudent('Mona',20,12,99,'computer')
p.display2()अति संक्षिप्त उत्तर
Advertisements
उत्तर
After correcting indentation, the code creates an object of Gstudent.
Output
Name : Mona
Age : 20
Roll No: 12
Marks : 99
stream: computer
Type of inheritance: Multilevel inheritance: person → student → Gstudent.
shaalaa.com
क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
