exam questions

Exam PCPP-32-101 All Questions

View all questions & answers for the PCPP-32-101 exam

Exam PCPP-32-101 topic 1 question 2 discussion

Actual exam question from Python Institute's PCPP-32-101
Question #: 2
Topic #: 1
[All PCPP-32-101 Questions]

Analyze the following snippet and select the statement that best describes it.

  • A. The code is an example of implicitly chained exceptions.
  • B. The code is erroneous as the OwnMath class does not inherit from any Exception type class
  • C. The code is fine and the script execution is not interrupted by any exception.
  • D. The code is an example of explicitly chained exceptions
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
deyoz
4 weeks, 1 day ago
Selected Answer: A
The answer is A 100 percent. Because you are trying to raise another exception while handling ZeroDivisionError using keyword "raise...from..." which is explicit chaining, but as OwnMath is not derived from any superclass exception, resulting in Typeerror. However, your previous exception will be preserved by the python, i.e. typeerror is linked to zerodivision error, which happened because of the __context__ attribute. So, this is implicit chaining.
upvoted 1 times
...
trebornamor
7 months, 3 weeks ago
Selected Answer: B
The answer is B. The OwnMath class needs inherit BaseException. class OwnMath(BaseException): pass
upvoted 1 times
...
ghozlane
9 months, 3 weeks ago
Selected Answer: B
ive tested this code .. the answer is B
upvoted 1 times
...
tankwayep
11 months, 1 week ago
Selected Answer: B
Answer is B
upvoted 1 times
...
_cherre_
1 year, 1 month ago
Selected Answer: B
I've tested this code and got the error TypeError: exceptions must derive from BaseException
upvoted 1 times
...
w_w_w_w_w_w
1 year, 1 month ago
Selected Answer: B
OwnMath should be derived from BaseException. Run this code and you'll get an exception. If it is derived, it's an example of explicitly chained exception.
upvoted 3 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 ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago