100% Latest & Updated Python Institute PCEP-30-02 Practice Test Questions, Exam Dumps & Verified Answers!
30 Days Free Updates, Instant Download!
Question 360
During a review of duplicate argument assignment raises TypeError, three independent Python 3 fragments are shown. Which THREE statements accurately describe their behavior? (Choose THREE.)Program A:
def f(a,b): return a+b
print(f(1,a=2,b=3))
Program B:
def f(x,y): return x+y
print(f(1,y=2))
Program C:
def f(x=1): return x
print(f(x=4))
- Program B prints '3'.
- Program A raises typeerror.
- Program A raises nameerror.
- Program C prints '4'.
- Program C prints '8'.
- Program B prints '6'.
Explanation
Correct Answers
A:Running Program B prints '3'. Providing a parameter both positionally and by keyword causes TypeError for multiple values.
B:Running Program A raises typeerror. Providing a parameter both positionally and by keyword causes TypeError for multiple values.
D:Running Program C prints '4'. Providing a parameter both positionally and by keyword causes TypeError for multiple values.
Incorrect Answers
C:Program A does not raises nameerror; its verified result is: Raises TypeError. Providing a parameter both positionally and by keyword causes TypeError for multiple values.
E:Program C does not produce '8'; its verified result is: Prints '4'. Providing a parameter both positionally and by keyword causes TypeError for multiple values.
F:Program B does not produce '6'; its verified result is: Prints '3'. Providing a parameter both positionally and by keyword causes TypeError for multiple values.
Question 361
A learner is checking ValueError versus TypeError in conversion. What is the exact printed result or uncaught exception?print(int("twelve"))
- Raises ValueError
- Raises TypeError
- Raises KeyError
- Raises IndexError
Explanation
Correct Answer
A:The snippet raises valueerror. int raises ValueError for text that cannot represent an integer; incompatible argument types raise TypeError.
Incorrect Answers
B:This predicts that the snippet raises typeerror, but executing the displayed Python 3 code raises valueerror. int raises ValueError for text that cannot represent an integer; incompatible argument types raise TypeError.
C:This predicts that the snippet raises keyerror, but executing the displayed Python 3 code raises valueerror. int raises ValueError for text that cannot represent an integer; incompatible argument types raise TypeError.
D:This predicts that the snippet raises indexerror, but executing the displayed Python 3 code raises valueerror. int raises ValueError for text that cannot represent an integer; incompatible argument types raise TypeError.
Question 362
A developer tests ValueError versus TypeError in conversion. The following code prints '13'. Which explanation best accounts for that observed behavior?print(int("12")+1)
- int raises ValueError for text that cannot represent an integer; incompatible argument types raise TypeError.
- Once a function returns, the remaining statements in that function call are not executed.
- A Python function without a reachable return statement returns the singleton None.
- An absent list index produces IndexError whereas a missing dictionary key produces KeyError.
Explanation
Correct Answer
A:This is the operative language rule for the code. It directly explains why the example prints '13'; the displayed behavior was independently reproduced by a Python 3 execution check.
Incorrect Answers
B:The early return versus later statements topic does not explain why the code prints '13'. The relevant Python rule is: int raises ValueError for text that cannot represent an integer; incompatible argument types raise TypeError.
C:The implicit None return topic does not explain why the code prints '13'. The relevant Python rule is: int raises ValueError for text that cannot represent an integer; incompatible argument types raise TypeError.
D:The IndexError and KeyError distinct topic does not explain why the code prints '13'. The relevant Python rule is: int raises ValueError for text that cannot represent an integer; incompatible argument types raise TypeError.
Question 363
A learner is checking ValueError versus TypeError in conversion. After this modification, what does Python 3 actually do?print(int(None))
- Raises IndexError
- Raises TypeError
- Raises ValueError
- Raises KeyError
Explanation
Correct Answer
B:The snippet raises typeerror. int raises ValueError for text that cannot represent an integer; incompatible argument types raise TypeError.
Incorrect Answers
A:This predicts that the snippet raises indexerror, but executing the displayed Python 3 code raises typeerror. int raises ValueError for text that cannot represent an integer; incompatible argument types raise TypeError.
C:This predicts that the snippet raises valueerror, but executing the displayed Python 3 code raises typeerror. int raises ValueError for text that cannot represent an integer; incompatible argument types raise TypeError.
D:This predicts that the snippet raises keyerror, but executing the displayed Python 3 code raises typeerror. int raises ValueError for text that cannot represent an integer; incompatible argument types raise TypeError.
Question 364
During a review of ValueError versus TypeError in conversion, three independent Python 3 fragments are shown. Which THREE statements accurately describe their behavior? (Choose THREE.)Program A:
print(int("12")+1)
Program B:
print(int(None))
Program C:
print(int("3.0"))
- Program A prints 'ab'.
- Program A prints '13'.
- Program C raises valueerror.
- Program B raises typeerror.
- Program C raises indexerror.
- Program B prints 'handled'.
Explanation
Correct Answers
B:Running Program A prints '13'. int raises ValueError for text that cannot represent an integer; incompatible argument types raise TypeError.
C:Running Program C raises valueerror. int raises ValueError for text that cannot represent an integer; incompatible argument types raise TypeError.
D:Running Program B raises typeerror. int raises ValueError for text that cannot represent an integer; incompatible argument types raise TypeError.
Incorrect Answers
A:Program A does not produce 'ab'; its verified result is: Prints '13'. int raises ValueError for text that cannot represent an integer; incompatible argument types raise TypeError.
E:Program C does not raises indexerror; its verified result is: Raises ValueError. int raises ValueError for text that cannot represent an integer; incompatible argument types raise TypeError.
F:Program B does not produce 'handled'; its verified result is: Raises TypeError. int raises ValueError for text that cannot represent an integer; incompatible argument types raise TypeError.
Question 365
A learner is checking LookupError ancestry. What is the exact printed result or uncaught exception?print(issubclass(IndexError,LookupError))
- Prints 'False'
- Prints '1'
- Prints '0'
- Prints 'True'
Explanation
Correct Answer
D:The snippetprints 'true'. IndexError and KeyError are distinct subclasses of LookupError and can be caught by its common superclass.
Incorrect Answers
A:This predicts that the snippet prints 'false', but executing the displayed Python 3 codeprints 'true'. IndexError and KeyError are distinct subclasses of LookupError and can be caught by its common superclass.
B:This predicts that the snippet prints '1', but executing the displayed Python 3 codeprints 'true'. IndexError and KeyError are distinct subclasses of LookupError and can be caught by its common superclass.
C:This predicts that the snippet prints '0', but executing the displayed Python 3 codeprints 'true'. IndexError and KeyError are distinct subclasses of LookupError and can be caught by its common superclass.
Question 366
A developer tests LookupError ancestry. The following code prints 'true'. Which explanation best accounts for that observed behavior?print(issubclass(KeyError,LookupError))
- IndexError and KeyError are distinct subclasses of LookupError and can be caught by its common superclass.
- ZeroDivisionError inherits from ArithmeticError which itself inherits from Exception.
- A global declaration makes assignment inside the function modify the module-level name.
- An except block for an unrelated exception does not intercept the error and execution fails at the uncaught exception.
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 ArithmeticError inheritance. It does not account for this example, whose result isprints 'true'. The relevant rule is: IndexError and KeyError are distinct subclasses of LookupError and can be caught by its common superclass.
C: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: IndexError and KeyError are distinct subclasses of LookupError and can be caught by its common superclass.
D:That statement describes the separate topic specific versus incorrect exception catch. It does not account for this example, whose result isprints 'true'. The relevant rule is: IndexError and KeyError are distinct subclasses of LookupError and can be caught by its common superclass.
Question 367
A learner is checking LookupError ancestry. After this modification, what does Python 3 actually do?print(issubclass(ValueError,LookupError))
- Prints 'False'
- Prints '1'
- Prints '0'
- Prints 'True'
Explanation
Correct Answer
A:The snippet prints 'false'. IndexError and KeyError are distinct subclasses of LookupError and can be caught by its common superclass.
Incorrect Answers
B:This predicts that the snippet prints '1', but executing the displayed Python 3 code prints 'false'. IndexError and KeyError are distinct subclasses of LookupError and can be caught by its common superclass.
C:This predicts that the snippet prints '0', but executing the displayed Python 3 code prints 'false'. IndexError and KeyError are distinct subclasses of LookupError and can be caught by its common superclass.
D:This predicts that the snippetprints 'true', but executing the displayed Python 3 code prints 'false'. IndexError and KeyError are distinct subclasses of LookupError and can be caught by its common superclass.
Question 368
During a review of LookupError ancestry, three independent Python 3 fragments are shown. Which THREE statements accurately describe their behavior? (Choose THREE.)Program A:
print(issubclass(KeyError,LookupError))
Program B:
print(issubclass(ValueError,LookupError))
Program C:
print(issubclass(LookupError,Exception))
- Program A prints 'true'.
- Program C prints 'none'.
- Program C prints 'true'.
- Program A prints 'even'.
- Program B prints 'index'.
- Program B prints 'false'.
Explanation
Correct Answers
A:Running Program Aprints 'true'. IndexError and KeyError are distinct subclasses of LookupError and can be caught by its common superclass.
C:Running Program Cprints 'true'. IndexError and KeyError are distinct subclasses of LookupError and can be caught by its common superclass.
F:Running Program B prints 'false'. IndexError and KeyError are distinct subclasses of LookupError and can be caught by its common superclass.
Incorrect Answers
B:Program C does not produce 'none'; its verified result is:prints 'True'. IndexError and KeyError are distinct subclasses of LookupError and can be caught by its common superclass.
D:Program A does not produce 'even'; its verified result is:prints 'True'. IndexError and KeyError are distinct subclasses of LookupError and can be caught by its common superclass.
E:Program B does not produce 'index'; its verified result is: Prints 'False'. IndexError and KeyError are distinct subclasses of LookupError and can be caught by its common superclass.
Question 369
A learner is checking ArithmeticError inheritance. What is the exact printed result or uncaught exception?print(issubclass(ZeroDivisionError,ArithmeticError))
- Prints '1'
- Prints 'True'
- Prints '0'
- Prints 'False'
Explanation
Correct Answer
B:The snippetprints 'true'. ZeroDivisionError inherits from ArithmeticError which itself inherits from Exception.
Incorrect Answers
A:This predicts that the snippet prints '1', but executing the displayed Python 3 codeprints 'true'. ZeroDivisionError inherits from ArithmeticError which itself inherits from Exception.
C:This predicts that the snippet prints '0', but executing the displayed Python 3 codeprints 'true'. ZeroDivisionError inherits from ArithmeticError which itself inherits from Exception.
D:This predicts that the snippet prints 'false', but executing the displayed Python 3 codeprints 'true'. ZeroDivisionError inherits from ArithmeticError which itself inherits from Exception.
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.
PCEP - Certified Entry-Level Python Programmer (PCEP-30-02) Practice Tests