हिंदी

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

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
     p=student('Mona',20,12,99)
p.display()
अति संक्षिप्त उत्तर
Advertisements

उत्तर

After correcting indentation, the code creates an object of student.

Output

Name : Mona
Age : 20
Roll No: 12
Marks : 99

Type of inheritance: Single inheritance (student inherits person).

shaalaa.com
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
अध्याय 4: Inheritance - EXERCISE [पृष्ठ ७८]

APPEARS IN

सीबीएसई Computer Science with Python [English] Class 12
अध्याय 4 Inheritance
EXERCISE | Q 14. a. | पृष्ठ ७८
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×