#question 93
class Super:
def make (self):
return 0
def doit (self):
return self.make()
class Sub_A(Super):
def make(self):
return 1
class Sub_B(Super)
pass
a = Sub_A()
b = Sub_B()
print(a.doit() + b.doit())
Tested, right answer C (it raises an exception)
Always is C.
You can fix "class SubB(Super):" and see the result in question nº 120
class Super:
def make (self):
pass
def doit (self):
return self.make()
class Sub_A(Super):
def make(self):
return 1
class Sub_B(Super):
pass
a = Sub_A()
b = Sub_B()
print(a.doit() + b.doit())
TypeError: unsupported operand type(s) for +: 'int' and 'NoneType'
Answer is B. Infuriating to see that just missing a colon and whoever wrote this assume code is wrong..
>>> class Super:
def make(self):
return 0
def doit(self):
return self.make()
>>> class Sub_A(Super):
def make(self):
return 1
>>> class Sub_B(Super):
pass
>>> a=Sub_A()
>>> b=Sub_B()
>>>
>>>
>>> print(a.doit() + b.doit())
upvoted 4 times
...
Log in to ExamTopics
Sign in:
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
deckman
Highly Voted 2 years, 6 months agoIamrandom
11 months agomacxsz
Highly Voted 2 years, 6 months agoseaverick
Most Recent 10 months, 1 week agoJos015
1 year agoricopro
1 year, 4 months agoRizos
1 year, 8 months agoandr3
1 year, 8 months agoJnanada
2 years, 3 months agostuartz
2 years, 5 months agosadako11
2 years, 9 months agoEfren
3 years ago