Get Unlimited Contributor Access to the all ExamTopics Exams!
Take advantage of PDF Files for 1000+ Exams along with community discussions and pass IT Certification Exams Easily.
#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 1 year, 11 months agoIamrandom
3 months, 3 weeks agomacxsz
Highly Voted 1 year, 11 months agoseaverick
Most Recent 3 months agoJos015
5 months, 2 weeks agoricopro
9 months agoRizos
1 year, 1 month agoandr3
1 year, 1 month agoJnanada
1 year, 8 months agostuartz
1 year, 10 months agosadako11
2 years, 2 months agoEfren
2 years, 5 months ago