Advertisements
Advertisements
Question
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()Code Writing
Advertisements
Solution
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 ofdef __init__(self):with missing/incorrect underscoresFirst.__init__(self)instead ofFirst.__init__(self):Second.__init__(self)instead ofSecond.__init__(self):t = Third()instead oft=Third()t=Third()
Output
first
second
that's itshaalaa.com
Is there an error in this question or solution?
