100% Latest & Updated Python Institute PCEP-30-02 Practice Test Questions, Exam Dumps & Verified Answers!
30 Days Free Updates, Instant Download!
Question 10
A developer tests indentation-defined code blocks. The following code prints 'visible'. Which explanation best accounts for that observed behavior?if False:
print("hidden")
print("visible")
- Multiplication and division bind before addition and subtraction unless parentheses override precedence.
- Indentation determines which statements are inside a Python suite; dedented statements run afterward.
- Python statements execute in source order; earlier assignments and prints take effect before later ones.
- A # outside a string begins a comment and does not change the preceding executable expression.
Explanation
Correct Answer
B:This is the operative language rule for the code. It directly explains why the example prints 'visible'; the displayed behavior was independently reproduced by a Python 3 execution check.
Incorrect Answers
A:The multiplication and addition precedence topic does not explain why the code prints 'visible'. The relevant Python rule is: Indentation determines which statements are inside a Python suite; dedented statements run afterward.
C:The sequential interpreter execution topic does not explain why the code prints 'visible'. The relevant Python rule is: Indentation determines which statements are inside a Python suite; dedented statements run afterward.
D:The comments and executable code topic does not explain why the code prints 'visible'. The relevant Python rule is: Indentation determines which statements are inside a Python suite; dedented statements run afterward.
Question 11
A learner is checking indentation-defined code blocks. After this modification, what does Python 3 actually do?n=4
if n>2:
n+=3
print(n)
- Prints '8'
- Prints '6'
- Prints '7'
- Prints '9'
Explanation
Correct Answer
C:The snippet prints '7'. Indentation determines which statements are inside a Python suite; dedented statements run afterward.
Incorrect Answers
A:This predicts that the snippet prints '8', but executing the displayed Python 3 code prints '7'. Indentation determines which statements are inside a Python suite; dedented statements run afterward.
B:This predicts that the snippet prints '6', but executing the displayed Python 3 code prints '7'. Indentation determines which statements are inside a Python suite; dedented statements run afterward.
D:This predicts that the snippet prints '9', but executing the displayed Python 3 code prints '7'. Indentation determines which statements are inside a Python suite; dedented statements run afterward.
Question 12
A learner is checking indentation-defined code blocks. Which final result follows from this separate test?x=0
if True:
x=2
x+=5
print(x)
- Prints '6'
- Prints '9'
- Prints '8'
- Prints '7'
Explanation
Correct Answer
D:The snippet prints '7'. Indentation determines which statements are inside a Python suite; dedented statements run afterward.
Incorrect Answers
A:This predicts that the snippet prints '6', but executing the displayed Python 3 code prints '7'. Indentation determines which statements are inside a Python suite; dedented statements run afterward.
B:This predicts that the snippet prints '9', but executing the displayed Python 3 code prints '7'. Indentation determines which statements are inside a Python suite; dedented statements run afterward.
C:This predicts that the snippet prints '8', but executing the displayed Python 3 code prints '7'. Indentation determines which statements are inside a Python suite; dedented statements run afterward.
Question 13
A learner is checking comments and executable code. What is the exact printed result or uncaught exception?print(2+3) # +100
- Prints '5'
- Prints '7'
- Prints '6'
- Prints '4'
Explanation
Correct Answer
A:The snippet prints '5'. A # outside a string begins a comment and does not change the preceding executable expression.
Incorrect Answers
B:This predicts that the snippet prints '7', but executing the displayed Python 3 code prints '5'. A # outside a string begins a comment and does not change the preceding executable expression.
C:This predicts that the snippet prints '6', but executing the displayed Python 3 code prints '5'. A # outside a string begins a comment and does not change the preceding executable expression.
D:This predicts that the snippet prints '4', but executing the displayed Python 3 code prints '5'. A # outside a string begins a comment and does not change the preceding executable expression.
Question 14
A developer tests comments and executable code. The following code prints '4'. Which explanation best accounts for that observed behavior?x=4 # x=12
print(x)
- Bitwise operations work on integer bits: & keeps common set bits, | combines them, and shifts move bit positions.
- The and and or operators short-circuit and return operands, not necessarily Boolean objects.
- Indentation determines which statements are inside a Python suite; dedented statements run afterward.
- A # outside a string begins a comment and does not change the preceding executable expression.
Explanation
Correct Answer
D:This is the operative language rule for the code. It directly explains why the example prints '4'; the displayed behavior was independently reproduced by a Python 3 execution check.
Incorrect Answers
A:The bitwise masking and shifts topic does not explain why the code prints '4'. The relevant Python rule is: A # outside a string begins a comment and does not change the preceding executable expression.
B:The short-circuit Boolean expressions topic does not explain why the code prints '4'. The relevant Python rule is: A # outside a string begins a comment and does not change the preceding executable expression.
C:The indentation-defined code blocks topic does not explain why the code prints '4'. The relevant Python rule is: A # outside a string begins a comment and does not change the preceding executable expression.
Question 15
A learner is checking comments and executable code. After this modification, what does Python 3 actually do?print("# not a comment")
- Prints '# not a comment'
- Prints '# not a comment?'
- Prints '# not a commen'
- Prints 'tnemmoc a ton #'
Explanation
Correct Answer
A:The snippet prints '# not a comment'. A # outside a string begins a comment and does not change the preceding executable expression.
Incorrect Answers
B:This predicts that the snippet prints '# not a comment?', but executing the displayed Python 3 code prints '# not a comment'. A # outside a string begins a comment and does not change the preceding executable expression.
C:This predicts that the snippet prints '# not a commen', but executing the displayed Python 3 code prints '# not a comment'. A # outside a string begins a comment and does not change the preceding executable expression.
D:This predicts that the snippet prints 'tnemmoc a ton #', but executing the displayed Python 3 code prints '# not a comment'. A # outside a string begins a comment and does not change the preceding executable expression.
Question 16
A learner is checking comments and executable code. Which final result follows from this separate test?a=9
# a=0
print(a)
- Prints '8'
- Prints '9'
- Prints '10'
- Prints '11'
Explanation
Correct Answer
B:The snippet prints '9'. A # outside a string begins a comment and does not change the preceding executable expression.
Incorrect Answers
A:This predicts that the snippet prints '8', but executing the displayed Python 3 code prints '9'. A # outside a string begins a comment and does not change the preceding executable expression.
C:This predicts that the snippet prints '10', but executing the displayed Python 3 code prints '9'. A # outside a string begins a comment and does not change the preceding executable expression.
D:This predicts that the snippet prints '11', but executing the displayed Python 3 code prints '9'. A # outside a string begins a comment and does not change the preceding executable expression.
Question 17
A learner is checking Boolean literals in numeric expressions. What is the exact printed result or uncaught exception?print(True+2)
- Prints '3'
- Prints '5'
- Prints '4'
- Prints '2'
Explanation
Correct Answer
A:The snippet prints '3'. Boolean True and False behave as integer one and zero in Python arithmetic while remaining Boolean values.
Incorrect Answers
B:This predicts that the snippet prints '5', but executing the displayed Python 3 code prints '3'. Boolean True and False behave as integer one and zero in Python arithmetic while remaining Boolean values.
C:This predicts that the snippet prints '4', but executing the displayed Python 3 code prints '3'. Boolean True and False behave as integer one and zero in Python arithmetic while remaining Boolean values.
D:This predicts that the snippet prints '2', but executing the displayed Python 3 code prints '3'. Boolean True and False behave as integer one and zero in Python arithmetic while remaining Boolean values.
Question 18
A developer tests Boolean literals in numeric expressions. The following code prints '4'. Which explanation best accounts for that observed behavior?print(False*9+4)
- Bitwise operations work on integer bits: & keeps common set bits, | combines them, and shifts move bit positions.
- Assignment rebinds a variable name to a new object; the new value determines later operations and its type.
- Prefix 0b, 0o and 0x specifies the base of an integer literal, and mixed-base arithmetic uses numeric values.
- Boolean True and False behave as integer one and zero in Python arithmetic while remaining Boolean values.
Explanation
Correct Answer
D:This is the operative language rule for the code. It directly explains why the example prints '4'; the displayed behavior was independently reproduced by a Python 3 execution check.
Incorrect Answers
A:The bitwise masking and shifts topic does not explain why the code prints '4'. The relevant Python rule is: Boolean True and False behave as integer one and zero in Python arithmetic while remaining Boolean values.
B:The variable rebinding across types topic does not explain why the code prints '4'. The relevant Python rule is: Boolean True and False behave as integer one and zero in Python arithmetic while remaining Boolean values.
C:The binary octal and hexadecimal integer literals topic does not explain why the code prints '4'. The relevant Python rule is: Boolean True and False behave as integer one and zero in Python arithmetic while remaining Boolean values.
Question 19
A learner is checking Boolean literals in numeric expressions. After this modification, what does Python 3 actually do?print(True==1)
- Prints 'True'
- Prints '1'
- Prints '0'
- Prints 'False'
Explanation
Correct Answer
A:The snippetprints 'true'. Boolean True and False behave as integer one and zero in Python arithmetic while remaining Boolean values.
Incorrect Answers
B:This predicts that the snippet prints '1', but executing the displayed Python 3 codeprints 'true'. Boolean True and False behave as integer one and zero in Python arithmetic while remaining Boolean values.
C:This predicts that the snippet prints '0', but executing the displayed Python 3 codeprints 'true'. Boolean True and False behave as integer one and zero in Python arithmetic while remaining Boolean values.
D:This predicts that the snippet prints 'false', but executing the displayed Python 3 codeprints 'true'. Boolean True and False behave as integer one and zero in Python arithmetic while remaining Boolean values.
Question 20
During a review of Boolean literals in numeric expressions, three independent Python 3 fragments are shown. Which TWO statements accurately describe their behavior? (Choose TWO.)Program A:
print(False*9+4)
Program B:
print(True==1)
Program C:
print(type(True).__name__)
- Program B prints '0\n2'.
- Program B prints 'true'.
- Program C prints '4\n9'.
- Program C prints 'bool'.
- Program A prints '7'.
Explanation
Correct Answers
B:Running Program Bprints 'true'. Boolean True and False behave as integer one and zero in Python arithmetic while remaining Boolean values.
D:Running Program C prints 'bool'. Boolean True and False behave as integer one and zero in Python arithmetic while remaining Boolean values.
Incorrect Answers
A:Program B does not produce '0\n2'; its verified result is:prints 'True'. Boolean True and False behave as integer one and zero in Python arithmetic while remaining Boolean values.
C:Program C does not produce '4\n9'; its verified result is: Prints 'bool'. Boolean True and False behave as integer one and zero in Python arithmetic while remaining Boolean values.
E:Program A does not produce '7'; its verified result is: Prints '4'. Boolean True and False behave as integer one and zero in Python arithmetic while remaining Boolean values.
PCEP - Certified Entry-Level Python Programmer (PCEP-30-02) Practice Tests