Exam PCAP All QuestionsBrowse all questions from this exam
Question 93

What is the expected behavior of the following code?

    Correct Answer: D

    C

    It raises an exception because there is no colon after Sub_B(Super)

Discussion
deckmanOption: B

I guess there's a Typo Error. A Syntax error is not an Exception (you cannot do try: except on that).

Iamrandom

Sorry but it is. issubclass(SyntaxError, Exception) --> True

macxszOption: B

If text were right, answer is: B. it outputs 1 Otherwise it raises an exception because it has a typo.

EfrenOption: B

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())

Jos015Option: C

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'

JnanadaOption: B

If text were right, answer is: B. it outputs 1

stuartz

One thing I've learned from doing these is to process like python does and check for syntax errors before doing anything else

seaverickOption: C

#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)

ricoproOption: B

>>> 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()) 1 >>>

Rizos

There are no indentation or typo issues in the exam!!!

andr3

did you pass the exam ?

sadako11Option: B

Another question with a possible typo! Without the typo the answer is B.