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

Unlimited Access

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.

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: C 🗳️
It raises an exception because there is no colon after Sub_B(Super)

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
deckman
Highly Voted 1 year, 11 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
3 months, 3 weeks ago
Sorry but it is. issubclass(SyntaxError, Exception) --> True
upvoted 1 times
...
...
macxsz
Highly Voted 1 year, 11 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 3 months 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
5 months, 2 weeks 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
9 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, 1 month ago
There are no indentation or typo issues in the exam!!!
upvoted 1 times
andr3
1 year, 1 month ago
did you pass the exam ?
upvoted 1 times
...
...
Jnanada
1 year, 8 months ago
If text were right, answer is: B. it outputs 1
upvoted 2 times
...
stuartz
1 year, 10 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, 2 months ago
Another question with a possible typo! Without the typo the answer is B.
upvoted 1 times
...
Efren
2 years, 5 months 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 ...