हिंदी

Rewrite the following code after removing errors. Underline each correction and write the output after correcting the code: class First(): def __init__(self):

Advertisements
Advertisements

प्रश्न

Rewrite the following code after removing errors. Underline each correction and write the output after correcting the code:

class First():
def __init__(self):
     print "first":
class Second(object):
def __init__(self):
     print "second"
class Third(First, Second):
def __init__(self):
     First.__init__(self):
     Second.__init__(self):
     print "that's it" 
t=Third()t=Third()
कोड लेखन
Advertisements

उत्तर

class First():

def __init__(self):
     print "first"

class Second(object):

def __init__(self): 
     print "second"

class Third(First, Second):

def __init__(self): 
     First.__init__(self) 
     Second.__init__(self) 
     print "that's it"

t = Third()

Corrections:

  • def __init__(self): instead of def __init__(self): with missing/incorrect underscores
  • First.__init__(self) instead of First.__init__(self):
  • Second.__init__(self) instead of Second.__init__(self):
  • t = Third() instead of t=Third()t=Third()

Output

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

APPEARS IN

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

Englishहिंदीमराठी


      Forgot password?
Use app×