100% Latest & Updated Python Institute PCEP-30-02 Practice Test Questions, Exam Dumps & Verified Answers!
30 Days Free Updates, Instant Download!
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.
Question 51
A learner is checking modulo with a negative divisor. After this modification, what does Python 3 actually do?print(-7//3,-7%3)
- Prints '-3 '
- Prints '-3 2?'
- Prints '-3 2'
- Prints '2 3-'
Explanation
Correct Answer
C:The snippet prints '-3 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 '-3 ', but executing the displayed Python 3 code prints '-3 2'. For integers, a == (a // b) * b + (a % b); the modulo result has the divisor sign when nonzero.
B:This predicts that the snippet prints '-3 2?', but executing the displayed Python 3 code prints '-3 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 '2 3-', but executing the displayed Python 3 code prints '-3 2'. For integers, a == (a // b) * b + (a % b); the modulo result has the divisor sign when nonzero.
Question 52
During a review of modulo with a negative divisor, three independent Python 3 fragments are shown. Which THREE statements accurately describe their behavior? (Choose THREE.)Program A:
print(7%-3)
Program B:
print(-7//3,-7%3)
Program C:
print(13%5)
- Program B prints 'goal'.
- Program A prints '-2'.
- Program A prints '64'.
- Program C prints '3'.
- Program B prints '-3 2'.
- Program C prints '1'.
Explanation
Correct Answers
B:Running Program A prints '-2'. For integers, a == (a // b) * b + (a % b); the modulo result has the divisor sign when nonzero.
D:Running Program C prints '3'. For integers, a == (a // b) * b + (a % b); the modulo result has the divisor sign when nonzero.
E:Running Program B prints '-3 2'. For integers, a == (a // b) * b + (a % b); the modulo result has the divisor sign when nonzero.
Incorrect Answers
A:Program B does not produce 'goal'; its verified result is: Prints '-3 2'. For integers, a == (a // b) * b + (a % b); the modulo result has the divisor sign when nonzero.
C:Program A does not produce '64'; its verified result is: Prints '-2'. For integers, a == (a // b) * b + (a % b); the modulo result has the divisor sign when nonzero.
F:Program C does not produce '1'; its verified result is: Prints '3'. For integers, a == (a // b) * b + (a % b); the modulo result has the divisor sign when nonzero.
Question 53
A learner is checking multiplication and addition precedence. What is the exact printed result or uncaught exception?print(2+3*4)
- Prints '14'
- Prints '13'
- Prints '15'
- Prints '16'
Explanation
Correct Answer
A:The snippet prints '14'. Multiplication and division bind before addition and subtraction unless parentheses override precedence.
Incorrect Answers
B:This predicts that the snippet prints '13', but executing the displayed Python 3 code prints '14'. Multiplication and division bind before addition and subtraction unless parentheses override precedence.
C:This predicts that the snippet prints '15', but executing the displayed Python 3 code prints '14'. Multiplication and division bind before addition and subtraction unless parentheses override precedence.
D:This predicts that the snippet prints '16', but executing the displayed Python 3 code prints '14'. Multiplication and division bind before addition and subtraction unless parentheses override precedence.
Question 54
A developer tests multiplication and addition precedence. The following code prints '20'. Which explanation best accounts for that observed behavior?print((2+3)*4)
- Prefix 0b, 0o and 0x specifies the base of an integer literal, and mixed-base arithmetic uses numeric values.
- Multiplication and division bind before addition and subtraction unless parentheses override precedence.
- A # outside a string begins a comment and does not change the preceding executable expression.
- Python identifiers distinguish lowercase and uppercase letters; names that differ in case are different bindings.
Explanation
Correct Answer
B:This is the operative language rule for the code. It directly explains why the example prints '20'; the displayed behavior was independently reproduced by a Python 3 execution check.
Incorrect Answers
A:The binary octal and hexadecimal integer literals topic does not explain why the code prints '20'. The relevant Python rule is: Multiplication and division bind before addition and subtraction unless parentheses override precedence.
C:The comments and executable code topic does not explain why the code prints '20'. The relevant Python rule is: Multiplication and division bind before addition and subtraction unless parentheses override precedence.
D:The case-sensitive identifiers topic does not explain why the code prints '20'. The relevant Python rule is: Multiplication and division bind before addition and subtraction unless parentheses override precedence.
Question 55
A learner is checking multiplication and addition precedence. After this modification, what does Python 3 actually do?print(19-8/2)
- Prints '17.0'
- Prints '16.0'
- Prints '15.0'
- Prints '14.0'
Explanation
Correct Answer
C:The snippet prints '15.0'. Multiplication and division bind before addition and subtraction unless parentheses override precedence.
Incorrect Answers
A:This predicts that the snippet prints '17.0', but executing the displayed Python 3 code prints '15.0'. Multiplication and division bind before addition and subtraction unless parentheses override precedence.
B:This predicts that the snippet prints '16.0', but executing the displayed Python 3 code prints '15.0'. Multiplication and division bind before addition and subtraction unless parentheses override precedence.
D:This predicts that the snippet prints '14.0', but executing the displayed Python 3 code prints '15.0'. Multiplication and division bind before addition and subtraction unless parentheses override precedence.
Question 56
During a review of multiplication and addition precedence, three independent Python 3 fragments are shown. Which THREE statements accurately describe their behavior? (Choose THREE.)Program A:
print((2+3)*4)
Program B:
print(19-8/2)
Program C:
print(6+12//4*2)
- Program A prints '-4'.
- Program C prints '12'.
- Program C prints '14'.
- Program A prints '20'.
- Program B prints '15.0'.
- Program B prints '0\n2'.
Explanation
Correct Answers
B:Running Program C prints '12'. Multiplication and division bind before addition and subtraction unless parentheses override precedence.
D:Running Program A prints '20'. Multiplication and division bind before addition and subtraction unless parentheses override precedence.
E:Running Program B prints '15.0'. Multiplication and division bind before addition and subtraction unless parentheses override precedence.
Incorrect Answers
A:Program A does not produce '-4'; its verified result is: Prints '20'. Multiplication and division bind before addition and subtraction unless parentheses override precedence.
C:Program C does not produce '14'; its verified result is: Prints '12'. Multiplication and division bind before addition and subtraction unless parentheses override precedence.
F:Program B does not produce '0\n2'; its verified result is: Prints '15.0'. Multiplication and division bind before addition and subtraction unless parentheses override precedence.
Question 57
A learner is checking bitwise masking and shifts. What is the exact printed result or uncaught exception?print(0b1101 & 0b1011)
- Prints '11'
- Prints '8'
- Prints '9'
- Prints '10'
Explanation
Correct Answer
C:The snippet prints '9'. Bitwise operations work on integer bits: & keeps common set bits, | combines them, and shifts move bit positions.
Incorrect Answers
A:This predicts that the snippet prints '11', but executing the displayed Python 3 code prints '9'. Bitwise operations work on integer bits: & keeps common set bits, | combines them, and shifts move bit positions.
B:This predicts that the snippet prints '8', but executing the displayed Python 3 code prints '9'. Bitwise operations work on integer bits: & keeps common set bits, | combines them, and shifts move bit positions.
D:This predicts that the snippet prints '10', but executing the displayed Python 3 code prints '9'. Bitwise operations work on integer bits: & keeps common set bits, | combines them, and shifts move bit positions.
Question 58
A developer tests bitwise masking and shifts. The following code prints '7'. Which explanation best accounts for that observed behavior?print(5 | 2)
- The sep parameter joins print arguments, and end replaces the trailing newline emitted by print.
- Multiplication and division bind before addition and subtraction unless parentheses override precedence.
- The and and or operators short-circuit and return operands, not necessarily Boolean objects.
- Bitwise operations work on integer bits: & keeps common set bits, | combines them, and shifts move bit positions.
Explanation
Correct Answer
D:This is the operative language rule for the code. It directly explains why the example prints '7'; the displayed behavior was independently reproduced by a Python 3 execution check.
Incorrect Answers
A:The print separators and line endings topic does not explain why the code prints '7'. The relevant Python rule is: Bitwise operations work on integer bits: & keeps common set bits, | combines them, and shifts move bit positions.
B:The multiplication and addition precedence topic does not explain why the code prints '7'. The relevant Python rule is: Bitwise operations work on integer bits: & keeps common set bits, | combines them, and shifts move bit positions.
C:The short-circuit Boolean expressions topic does not explain why the code prints '7'. The relevant Python rule is: Bitwise operations work on integer bits: & keeps common set bits, | combines them, and shifts move bit positions.
Question 59
A learner is checking bitwise masking and shifts. After this modification, what does Python 3 actually do?print(3<<2)
- Prints '11'
- Prints '13'
- Prints '14'
- Prints '12'
Explanation
Correct Answer
D:The snippet prints '12'. Bitwise operations work on integer bits: & keeps common set bits, | combines them, and shifts move bit positions.
Incorrect Answers
A:This predicts that the snippet prints '11', but executing the displayed Python 3 code prints '12'. Bitwise operations work on integer bits: & keeps common set bits, | combines them, and shifts move bit positions.
B:This predicts that the snippet prints '13', but executing the displayed Python 3 code prints '12'. Bitwise operations work on integer bits: & keeps common set bits, | combines them, and shifts move bit positions.
C:This predicts that the snippet prints '14', but executing the displayed Python 3 code prints '12'. Bitwise operations work on integer bits: & keeps common set bits, | combines them, and shifts move bit positions.
Question 60
During a review of bitwise masking and shifts, three independent Python 3 fragments are shown. Which THREE statements accurately describe their behavior? (Choose THREE.)Program A:
print(5 | 2)
Program B:
print(3<<2)
Program C:
print(12>>2 ^ 1)
- Program A prints '7'.
- Program B prints '12'.
- Program A prints '5'.
- Program B prints '16'.
- Program C prints '2'.
- Program C prints '4'.
Explanation
Correct Answers
A:Running Program A prints '7'. Bitwise operations work on integer bits: & keeps common set bits, | combines them, and shifts move bit positions.
B:Running Program B prints '12'. Bitwise operations work on integer bits: & keeps common set bits, | combines them, and shifts move bit positions.
E:Running Program C prints '2'. Bitwise operations work on integer bits: & keeps common set bits, | combines them, and shifts move bit positions.
Incorrect Answers
C:Program A does not produce '5'; its verified result is: Prints '7'. Bitwise operations work on integer bits: & keeps common set bits, | combines them, and shifts move bit positions.
D:Program B does not produce '16'; its verified result is: Prints '12'. Bitwise operations work on integer bits: & keeps common set bits, | combines them, and shifts move bit positions.
F:Program C does not produce '4'; its verified result is: Prints '2'. Bitwise operations work on integer bits: & keeps common set bits, | combines them, and shifts move bit positions.
PCEP - Certified Entry-Level Python Programmer (PCEP-30-02) Practice Tests