100% Latest & Updated Python Institute PCEP-30-02 Practice Test Questions, Exam Dumps & Verified Answers!
30 Days Free Updates, Instant Download!
Question 370
A developer tests ArithmeticError inheritance. The following code prints 'true'. Which explanation best accounts for that observed behavior?print(issubclass(ArithmeticError,Exception))
- A recursive sum decreases the input until its base case and combines each return value on the way back.
- An inner try-except handles matching exceptions; otherwise an outer compatible handler can receive the propagated error.
- ZeroDivisionError inherits from ArithmeticError which itself inherits from Exception.
- Providing a parameter both positionally and by keyword causes TypeError for multiple values.
Explanation
Correct Answer
C:This is the operative language rule for the code. It directly explains why the exampleprints 'true'; the displayed behavior was independently reproduced by a Python 3 execution check.
Incorrect Answers
A:That statement describes the separate topic recursive summation. It does not account for this example, whose result isprints 'true'. The relevant rule is: ZeroDivisionError inherits from ArithmeticError which itself inherits from Exception.
B:That statement describes the separate topic nested try except responsibility. It does not account for this example, whose result isprints 'true'. The relevant rule is: ZeroDivisionError inherits from ArithmeticError which itself inherits from Exception.
D:That statement describes the separate topic duplicate argument assignment raises TypeError. It does not account for this example, whose result isprints 'true'. The relevant rule is: ZeroDivisionError inherits from ArithmeticError which itself inherits from Exception.
Question 371
A learner is checking ArithmeticError inheritance. After this modification, what does Python 3 actually do?print(issubclass(KeyError,ArithmeticError))
- Prints '0'
- Prints '1'
- Prints 'False'
- Prints 'True'
Explanation
Correct Answer
C:The snippet prints 'false'. ZeroDivisionError inherits from ArithmeticError which itself inherits from Exception.
Incorrect Answers
A:This predicts that the snippet prints '0', but executing the displayed Python 3 code prints 'false'. ZeroDivisionError inherits from ArithmeticError which itself inherits from Exception.
B:This predicts that the snippet prints '1', but executing the displayed Python 3 code prints 'false'. ZeroDivisionError inherits from ArithmeticError which itself inherits from Exception.
D:This predicts that the snippetprints 'true', but executing the displayed Python 3 code prints 'false'. ZeroDivisionError inherits from ArithmeticError which itself inherits from Exception.
Question 372
During a review of ArithmeticError inheritance, three independent Python 3 fragments are shown. Which THREE statements accurately describe their behavior? (Choose THREE.)Program A:
print(issubclass(ArithmeticError,Exception))
Program B:
print(issubclass(KeyError,ArithmeticError))
Program C:
print(issubclass(ZeroDivisionError,LookupError))
- Program A prints 'true'.
- Program A prints 'even'.
- Program B prints 'false'.
- Program B prints 'index'.
- Program C prints 'outer'.
- Program C prints 'false'.
Explanation
Correct Answers
A:Running Program Aprints 'true'. ZeroDivisionError inherits from ArithmeticError which itself inherits from Exception.
C:Running Program B prints 'false'. ZeroDivisionError inherits from ArithmeticError which itself inherits from Exception.
F:Running Program C prints 'false'. ZeroDivisionError inherits from ArithmeticError which itself inherits from Exception.
Incorrect Answers
B:Program A does not produce 'even'; its verified result is:prints 'True'. ZeroDivisionError inherits from ArithmeticError which itself inherits from Exception.
D:Program B does not produce 'index'; its verified result is: Prints 'False'. ZeroDivisionError inherits from ArithmeticError which itself inherits from Exception.
E:Program C does not produce 'outer'; its verified result is: Prints 'False'. ZeroDivisionError inherits from ArithmeticError which itself inherits from Exception.
Question 373
A learner is checking BaseException versus Exception. What is the exact printed result or uncaught exception?print(issubclass(KeyboardInterrupt,Exception))
- Prints '0'
- Prints 'True'
- Prints '1'
- Prints 'False'
Explanation
Correct Answer
D:The snippet prints 'false'. KeyboardInterrupt and SystemExit derive from BaseException but not from the Exception subclass.
Incorrect Answers
A:This predicts that the snippet prints '0', but executing the displayed Python 3 code prints 'false'. KeyboardInterrupt and SystemExit derive from BaseException but not from the Exception subclass.
B:This predicts that the snippetprints 'true', but executing the displayed Python 3 code prints 'false'. KeyboardInterrupt and SystemExit derive from BaseException but not from the Exception subclass.
C:This predicts that the snippet prints '1', but executing the displayed Python 3 code prints 'false'. KeyboardInterrupt and SystemExit derive from BaseException but not from the Exception subclass.
Question 374
A developer tests BaseException versus Exception. The following code prints 'true'. Which explanation best accounts for that observed behavior?print(issubclass(SystemExit,BaseException))
- KeyboardInterrupt and SystemExit derive from BaseException but not from the Exception subclass.
- The except clause matching the raised exception class handles the error and allows execution to continue.
- Once a function returns, the remaining statements in that function call are not executed.
- A global declaration makes assignment inside the function modify the module-level name.
Explanation
Correct Answer
A:This is the operative language rule for the code. It directly explains why the exampleprints 'true'; the displayed behavior was independently reproduced by a Python 3 execution check.
Incorrect Answers
B:That statement describes the separate topic exact exception handler selection. It does not account for this example, whose result isprints 'true'. The relevant rule is: KeyboardInterrupt and SystemExit derive from BaseException but not from the Exception subclass.
C:That statement describes the separate topic early return versus later statements. It does not account for this example, whose result isprints 'true'. The relevant rule is: KeyboardInterrupt and SystemExit derive from BaseException but not from the Exception subclass.
D:That statement describes the separate topic global declaration changes module binding. It does not account for this example, whose result isprints 'true'. The relevant rule is: KeyboardInterrupt and SystemExit derive from BaseException but not from the Exception subclass.
Question 375
A learner is checking BaseException versus Exception. After this modification, what does Python 3 actually do?print(issubclass(SystemExit,Exception))
- Prints '1'
- Prints 'False'
- Prints 'True'
- Prints '0'
Explanation
Correct Answer
B:The snippet prints 'false'. KeyboardInterrupt and SystemExit derive from BaseException but not from the Exception subclass.
Incorrect Answers
A:This predicts that the snippet prints '1', but executing the displayed Python 3 code prints 'false'. KeyboardInterrupt and SystemExit derive from BaseException but not from the Exception subclass.
C:This predicts that the snippetprints 'true', but executing the displayed Python 3 code prints 'false'. KeyboardInterrupt and SystemExit derive from BaseException but not from the Exception subclass.
D:This predicts that the snippet prints '0', but executing the displayed Python 3 code prints 'false'. KeyboardInterrupt and SystemExit derive from BaseException but not from the Exception subclass.
Question 376
During a review of BaseException versus Exception, three independent Python 3 fragments are shown. Which THREE statements accurately describe their behavior? (Choose THREE.)Program A:
print(issubclass(SystemExit,BaseException))
Program B:
print(issubclass(SystemExit,Exception))
Program C:
print(issubclass(KeyboardInterrupt,BaseException))
- Program C prints 'true'.
- Program B prints 'broad'.
- Program C prints 'none'.
- Program A prints 'true'.
- Program B prints 'false'.
- Program A prints 'even'.
Explanation
Correct Answers
A:Running Program Cprints 'true'. KeyboardInterrupt and SystemExit derive from BaseException but not from the Exception subclass.
D:Running Program Aprints 'true'. KeyboardInterrupt and SystemExit derive from BaseException but not from the Exception subclass.
E:Running Program B prints 'false'. KeyboardInterrupt and SystemExit derive from BaseException but not from the Exception subclass.
Incorrect Answers
B:Program B does not produce 'broad'; its verified result is: Prints 'False'. KeyboardInterrupt and SystemExit derive from BaseException but not from the Exception subclass.
C:Program C does not produce 'none'; its verified result is:prints 'True'. KeyboardInterrupt and SystemExit derive from BaseException but not from the Exception subclass.
F:Program A does not produce 'even'; its verified result is:prints 'True'. KeyboardInterrupt and SystemExit derive from BaseException but not from the Exception subclass.
Question 377
A learner is checking IndexError and KeyError distinct. What is the exact printed result or uncaught exception?print([1,2][3])
- Raises TypeError
- Raises ValueError
- Raises KeyError
- Raises IndexError
Explanation
Correct Answer
D:The snippet raises indexerror. An absent list index produces IndexError whereas a missing dictionary key produces KeyError.
Incorrect Answers
A:This predicts that the snippet raises typeerror, but executing the displayed Python 3 code raises indexerror. An absent list index produces IndexError whereas a missing dictionary key produces KeyError.
B:This predicts that the snippet raises valueerror, but executing the displayed Python 3 code raises indexerror. An absent list index produces IndexError whereas a missing dictionary key produces KeyError.
C:This predicts that the snippet raises keyerror, but executing the displayed Python 3 code raises indexerror. An absent list index produces IndexError whereas a missing dictionary key produces KeyError.
Question 378
A developer tests IndexError and KeyError distinct. The following code raises keyerror. Which explanation best accounts for that observed behavior?print({"x":1}["y"])
- An uncaught exception raised inside a function propagates to the caller where a matching except can catch it.
- An absent list index produces IndexError whereas a missing dictionary key produces KeyError.
- Exception handlers are checked in order; a broad superclass handler before a specific one makes the later one unreachable.
- The result returned by one function can be passed directly as an argument to another function.
Explanation
Correct Answer
B:This is the operative language rule for the code. It directly explains why the example raises keyerror; the displayed behavior was independently reproduced by a Python 3 execution check.
Incorrect Answers
A:The exceptions propagate across function calls topic does not explain why the code raises keyerror. The relevant Python rule is: An absent list index produces IndexError whereas a missing dictionary key produces KeyError.
C:The first matching except branch topic does not explain why the code raises keyerror. The relevant Python rule is: An absent list index produces IndexError whereas a missing dictionary key produces KeyError.
D:The function call composition topic does not explain why the code raises keyerror. The relevant Python rule is: An absent list index produces IndexError whereas a missing dictionary key produces KeyError.
Question 379
A learner is checking IndexError and KeyError distinct. After this modification, what does Python 3 actually do?print([5,6][-1])
- Prints '8'
- Prints '5'
- Prints '6'
- Prints '7'
Explanation
Correct Answer
C:The snippet prints '6'. An absent list index produces IndexError whereas a missing dictionary key produces KeyError.
Incorrect Answers
A:This predicts that the snippet prints '8', but executing the displayed Python 3 code prints '6'. An absent list index produces IndexError whereas a missing dictionary key produces KeyError.
B:This predicts that the snippet prints '5', but executing the displayed Python 3 code prints '6'. An absent list index produces IndexError whereas a missing dictionary key produces KeyError.
D:This predicts that the snippet prints '7', but executing the displayed Python 3 code prints '6'. An absent list index produces IndexError whereas a missing dictionary key produces KeyError.
Question 380
During a review of IndexError and KeyError distinct, three independent Python 3 fragments are shown. Which THREE statements accurately describe their behavior? (Choose THREE.)Program A:
print({"x":1}["y"])
Program B:
print([5,6][-1])
Program C:
print({"a":9}["a"])
- Program B prints '5'.
- Program A prints '[1, 7]'.
- Program B prints '6'.
- Program C prints '9'.
- Program C prints '2'.
- Program A raises keyerror.
Explanation
Correct Answers
C:Running Program B prints '6'. An absent list index produces IndexError whereas a missing dictionary key produces KeyError.
D:Running Program C prints '9'. An absent list index produces IndexError whereas a missing dictionary key produces KeyError.
F:Running Program A raises keyerror. An absent list index produces IndexError whereas a missing dictionary key produces KeyError.
Incorrect Answers
A:Program B does not produce '5'; its verified result is: Prints '6'. An absent list index produces IndexError whereas a missing dictionary key produces KeyError.
B:Program A does not produce '[1, 7]'; its verified result is: Raises KeyError. An absent list index produces IndexError whereas a missing dictionary key produces KeyError.
E:Program C does not produce '2'; its verified result is: Prints '9'. An absent list index produces IndexError whereas a missing dictionary key produces KeyError.
PCEP - Certified Entry-Level Python Programmer (PCEP-30-02) Practice Tests