Welcome to ExamTopics
ExamTopics Logo
- Expert Verified, Online, Free.
exam questions

Exam PCAP All Questions

View all questions & answers for the PCAP exam

Exam PCAP topic 1 question 93 discussion

Actual exam question from Python Institute's PCAP
Question #: 93
Topic #: 1
[All PCAP Questions]

What is the expected behavior of the following code?

  • A. it outputs 0
  • B. it outputs 1
  • C. it raises an exception
  • D. it outputs 2
Show Suggested Answer Hide Answer
Suggested Answer: B 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
deckman
Highly Voted 2 years, 6 months ago
Selected Answer: B
I guess there's a Typo Error. A Syntax error is not an Exception (you cannot do try: except on that).
upvoted 6 times
Iamrandom
11 months ago
Sorry but it is. issubclass(SyntaxError, Exception) --> True
upvoted 1 times
...
...
macxsz
Highly Voted 2 years, 6 months ago
Selected Answer: B
If text were right, answer is: B. it outputs 1 Otherwise it raises an exception because it has a typo.
upvoted 5 times
...
seaverick
Most Recent 10 months, 1 week ago
#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)
upvoted 1 times
...
Jos015
1 year ago
Selected Answer: 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'
upvoted 2 times
...
ricopro
1 year, 4 months ago
Selected Answer: 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 >>>
upvoted 1 times
...
Rizos
1 year, 8 months ago
There are no indentation or typo issues in the exam!!!
upvoted 1 times
andr3
1 year, 8 months ago
did you pass the exam ?
upvoted 1 times
...
...
Jnanada
2 years, 3 months ago
If text were right, answer is: B. it outputs 1
upvoted 2 times
...
stuartz
2 years, 5 months ago
One thing I've learned from doing these is to process like python does and check for syntax errors before doing anything else
upvoted 2 times
...
sadako11
2 years, 9 months ago
Another question with a possible typo! Without the typo the answer is B.
upvoted 1 times
...
Efren
3 years ago
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
...
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.

SaveCancel
Loading ...