100% Latest & Updated Python Institute PCEP-30-02 Practice Test Questions, Exam Dumps & Verified Answers!
30 Days Free Updates, Instant Download!
Question 40
During a review of right-associative exponentiation, three independent Python 3 fragments are shown. Which TWO statements accurately describe their behavior? (Choose TWO.)Program A:
print((2**3)**2)
Program B:
print(3**2**2)
Program C:
print(4**(1+1))
- Program B prints '81'.
- Program C prints '14'.
- Program C prints '16'.
- Program A prints '-3'.
- Program B prints '-2'.
Explanation
Correct Answers
A:Running Program B prints '81'. A chain of exponentiation operators groups from the right unless parentheses explicitly change the grouping.
C:Running Program C prints '16'. A chain of exponentiation operators groups from the right unless parentheses explicitly change the grouping.
Incorrect Answers
B:Program C does not produce '14'; its verified result is: Prints '16'. A chain of exponentiation operators groups from the right unless parentheses explicitly change the grouping.
D:Program A does not produce '-3'; its verified result is: Prints '64'. A chain of exponentiation operators groups from the right unless parentheses explicitly change the grouping.
E:Program B does not produce '-2'; its verified result is: Prints '81'. A chain of exponentiation operators groups from the right unless parentheses explicitly change the grouping.
Question 41
A learner is checking unary minus relative to exponentiation. What is the exact printed result or uncaught exception?print(-2**2)
- Prints '-3'
- Prints '-5'
- Prints '-2'
- Prints '-4'
Explanation
Correct Answer
D:The snippet prints '-4'. Exponentiation binds before a leading unary minus, so -a**b negates the power rather than the base.
Incorrect Answers
A:This predicts that the snippet prints '-3', but executing the displayed Python 3 code prints '-4'. Exponentiation binds before a leading unary minus, so -a**b negates the power rather than the base.
B:This predicts that the snippet prints '-5', but executing the displayed Python 3 code prints '-4'. Exponentiation binds before a leading unary minus, so -a**b negates the power rather than the base.
C:This predicts that the snippet prints '-2', but executing the displayed Python 3 code prints '-4'. Exponentiation binds before a leading unary minus, so -a**b negates the power rather than the base.
Question 42
A developer tests unary minus relative to exponentiation. The following code prints '4'. Which explanation best accounts for that observed behavior?print((-2)**2)
- The and and or operators short-circuit and return operands, not necessarily Boolean objects.
- Exponentiation binds before a leading unary minus, so -a**b negates the power rather than the base.
- Indentation determines which statements are inside a Python suite; dedented statements run afterward.
- Boolean True and False behave as integer one and zero in Python arithmetic while remaining Boolean values.
Explanation
Correct Answer
B: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 short-circuit Boolean expressions topic does not explain why the code prints '4'. The relevant Python rule is: Exponentiation binds before a leading unary minus, so -a**b negates the power rather than the base.
C:The indentation-defined code blocks topic does not explain why the code prints '4'. The relevant Python rule is: Exponentiation binds before a leading unary minus, so -a**b negates the power rather than the base.
D:The Boolean literals in numeric expressions topic does not explain why the code prints '4'. The relevant Python rule is: Exponentiation binds before a leading unary minus, so -a**b negates the power rather than the base.
Question 43
A learner is checking unary minus relative to exponentiation. After this modification, what does Python 3 actually do?print(-3**3)
- Prints '-25'
- Prints '-26'
- Prints '-28'
- Prints '-27'
Explanation
Correct Answer
D:The snippet prints '-27'. Exponentiation binds before a leading unary minus, so -a**b negates the power rather than the base.
Incorrect Answers
A:This predicts that the snippet prints '-25', but executing the displayed Python 3 code prints '-27'. Exponentiation binds before a leading unary minus, so -a**b negates the power rather than the base.
B:This predicts that the snippet prints '-26', but executing the displayed Python 3 code prints '-27'. Exponentiation binds before a leading unary minus, so -a**b negates the power rather than the base.
C:This predicts that the snippet prints '-28', but executing the displayed Python 3 code prints '-27'. Exponentiation binds before a leading unary minus, so -a**b negates the power rather than the base.
Question 44
During a review of unary minus relative to exponentiation, three independent Python 3 fragments are shown. Which TWO statements accurately describe their behavior? (Choose TWO.)Program A:
print((-2)**2)
Program B:
print(-3**3)
Program C:
print(-2**3+1)
- Program C prints '-7'.
- Program B prints '-27'.
- Program A prints '6'.
- Program B prints '123'.
- Program C prints '16'.
Explanation
Correct Answers
A:Running Program C prints '-7'. Exponentiation binds before a leading unary minus, so -a**b negates the power rather than the base.
B:Running Program B prints '-27'. Exponentiation binds before a leading unary minus, so -a**b negates the power rather than the base.
Incorrect Answers
C:Program A does not produce '6'; its verified result is: Prints '4'. Exponentiation binds before a leading unary minus, so -a**b negates the power rather than the base.
D:Program B does not produce '123'; its verified result is: Prints '-27'. Exponentiation binds before a leading unary minus, so -a**b negates the power rather than the base.
E:Program C does not produce '16'; its verified result is: Prints '-7'. Exponentiation binds before a leading unary minus, so -a**b negates the power rather than the base.
Question 45
A learner is checking true division versus floor division. What is the exact printed result or uncaught exception?print(7/2,7//2)
- Prints '3.5 3?'
- Prints '3 5.3'
- Prints '3.5 '
- Prints '3.5 3'
Explanation
Correct Answer
D:The snippet prints '3.5 3'. The / operator returns a float whereas // floors the quotient toward negative infinity.
Incorrect Answers
A:This predicts that the snippet prints '3.5 3?', but executing the displayed Python 3 code prints '3.5 3'. The / operator returns a float whereas // floors the quotient toward negative infinity.
B:This predicts that the snippet prints '3 5.3', but executing the displayed Python 3 code prints '3.5 3'. The / operator returns a float whereas // floors the quotient toward negative infinity.
C:This predicts that the snippet prints '3.5 ', but executing the displayed Python 3 code prints '3.5 3'. The / operator returns a float whereas // floors the quotient toward negative infinity.
Question 46
A developer tests true division versus floor division. The following code prints '-4'. Which explanation best accounts for that observed behavior?print(-7//2)
- The / operator returns a float whereas // floors the quotient toward negative infinity.
- Bitwise operations work on integer bits: & keeps common set bits, | combines them, and shifts move bit positions.
- Prefix 0b, 0o and 0x specifies the base of an integer literal, and mixed-base arithmetic uses numeric values.
- The sep parameter joins print arguments, and end replaces the trailing newline emitted by print.
Explanation
Correct Answer
A: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
B:The bitwise masking and shifts topic does not explain why the code prints '-4'. The relevant Python rule is: The / operator returns a float whereas // floors the quotient toward negative infinity.
C:The binary octal and hexadecimal integer literals topic does not explain why the code prints '-4'. The relevant Python rule is: The / operator returns a float whereas // floors the quotient toward negative infinity.
D:The print separators and line endings topic does not explain why the code prints '-4'. The relevant Python rule is: The / operator returns a float whereas // floors the quotient toward negative infinity.
Question 47
A learner is checking true division versus floor division. After this modification, what does Python 3 actually do?print(8//3,8/3)
- Prints '5666666666666666.2 2'
- Prints '2 2.666666666666666'
- Prints '2 2.6666666666666665'
- Prints '2 2.6666666666666665?'
Explanation
Correct Answer
C:The snippet prints '2 2.6666666666666665'. The / operator returns a float whereas // floors the quotient toward negative infinity.
Incorrect Answers
A:This predicts that the snippet prints '5666666666666666.2 2', but executing the displayed Python 3 code prints '2 2.6666666666666665'. The / operator returns a float whereas // floors the quotient toward negative infinity.
B:This predicts that the snippet prints '2 2.666666666666666', but executing the displayed Python 3 code prints '2 2.6666666666666665'. The / operator returns a float whereas // floors the quotient toward negative infinity.
D:This predicts that the snippet prints '2 2.6666666666666665?', but executing the displayed Python 3 code prints '2 2.6666666666666665'. The / operator returns a float whereas // floors the quotient toward negative infinity.
Question 48
During a review of true division versus floor division, three independent Python 3 fragments are shown. Which THREE statements accurately describe their behavior? (Choose THREE.)Program A:
print(-7//2)
Program B:
print(8//3,8/3)
Program C:
print(5//-2)
- Program B prints '# not a comment'.
- Program A prints '14'.
- Program C prints '-3'.
- Program C prints '64'.
- Program A prints '-4'.
- Program B prints '2 2.6666666666666665'.
Explanation
Correct Answers
C:Running Program C prints '-3'. The / operator returns a float whereas // floors the quotient toward negative infinity.
E:Running Program A prints '-4'. The / operator returns a float whereas // floors the quotient toward negative infinity.
F:Running Program B prints '2 2.6666666666666665'. The / operator returns a float whereas // floors the quotient toward negative infinity.
Incorrect Answers
A:Program B does not produce '# not a comment'; its verified result is: Prints '2 2.6666666666666665'. The / operator returns a float whereas // floors the quotient toward negative infinity.
B:Program A does not produce '14'; its verified result is: Prints '-4'. The / operator returns a float whereas // floors the quotient toward negative infinity.
D:Program C does not produce '64'; its verified result is: Prints '-3'. The / operator returns a float whereas // floors the quotient toward negative infinity.
Question 49
A learner is checking modulo with a negative divisor. What is the exact printed result or uncaught exception?print(-7%3)
- Prints '4'
- Prints '2'
- Prints '1'
- Prints '3'
Explanation
Correct Answer
B:The snippet prints '2'. For integers, a == (a // b) * b + (a % b); the modulo result has the divisor sign when nonzero.
Incorrect Answers
A:This predicts that the snippet prints '4', but executing the displayed Python 3 code prints '2'. For integers, a == (a // b) * b + (a % b); the modulo result has the divisor sign when nonzero.
C:This predicts that the snippet prints '1', but executing the displayed Python 3 code prints '2'. For integers, a == (a // b) * b + (a % b); the modulo result has the divisor sign when nonzero.
D:This predicts that the snippet prints '3', but executing the displayed Python 3 code prints '2'. For integers, a == (a // b) * b + (a % b); the modulo result has the divisor sign when nonzero.
Question 50
A developer tests modulo with a negative divisor. The following code prints '-2'. Which explanation best accounts for that observed behavior?print(7%-3)
- Exponentiation binds before a leading unary minus, so -a**b negates the power rather than the base.
- input returns a string; numeric calculations require explicit int or float conversion when text is provided.
- Python identifiers distinguish lowercase and uppercase letters; names that differ in case are different bindings.
- For integers, a == (a // b) * b + (a % b); the modulo result has the divisor sign when nonzero.
Explanation
Correct Answer
D:This is the operative language rule for the code. It directly explains why the example prints '-2'; the displayed behavior was independently reproduced by a Python 3 execution check.
Incorrect Answers
A:The unary minus relative to exponentiation topic does not explain why the code prints '-2'. The relevant Python rule is: For integers, a == (a // b) * b + (a % b); the modulo result has the divisor sign when nonzero.
B:The input strings and explicit conversion topic does not explain why the code prints '-2'. The relevant Python rule is: For integers, a == (a // b) * b + (a % b); the modulo result has the divisor sign when nonzero.
C:The case-sensitive identifiers topic does not explain why the code prints '-2'. The relevant Python rule is: For integers, a == (a // b) * b + (a % b); the modulo result has the divisor sign when nonzero.
PCEP - Certified Entry-Level Python Programmer (PCEP-30-02) Practice Tests