100% Latest & Updated Python Institute PCEP-30-02 Practice Test Questions, Exam Dumps & Verified Answers!
30 Days Free Updates, Instant Download!
Question 110
A developer tests not reverses Boolean conditions. The following code prints 'true'. Which explanation best accounts for that observed behavior?label=""
print(not label)
- The in operator tests membership in a sequence or collection, not positional arithmetic equality.
- The else suite attached to while executes after normal condition exhaustion, not after break.
- A negative range step decreases values and still excludes the stop bound.
- The not operator inverts truthiness; it does not numerically negate an operand.
Explanation
Correct Answer
D: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 membership-based conditional. It does not account for this example, whose result isprints 'true'. The relevant rule is: The not operator inverts truthiness; it does not numerically negate an operand.
B:That statement describes the separate topic while else semantics. It does not account for this example, whose result isprints 'true'. The relevant rule is: The not operator inverts truthiness; it does not numerically negate an operand.
C:That statement describes the separate topic range descending with negative step. It does not account for this example, whose result isprints 'true'. The relevant rule is: The not operator inverts truthiness; it does not numerically negate an operand.
Question 111
A learner is checking not reverses Boolean conditions. After this modification, what does Python 3 actually do?value=3
print(not(value>4))
- Prints 'True'
- Prints '1'
- Prints 'False'
- Prints '0'
Explanation
Correct Answer
A:The snippetprints 'true'. The not operator inverts truthiness; it does not numerically negate an operand.
Incorrect Answers
B:This predicts that the snippet prints '1', but executing the displayed Python 3 codeprints 'true'. The not operator inverts truthiness; it does not numerically negate an operand.
C:This predicts that the snippet prints 'false', but executing the displayed Python 3 codeprints 'true'. The not operator inverts truthiness; it does not numerically negate an operand.
D:This predicts that the snippet prints '0', but executing the displayed Python 3 codeprints 'true'. The not operator inverts truthiness; it does not numerically negate an operand.
Question 112
During a review of not reverses Boolean conditions, three independent Python 3 fragments are shown. Which TWO statements accurately describe their behavior? (Choose TWO.)Program A:
label=""
print(not label)
Program B:
value=3
print(not(value>4))
Program C:
flag=True
if not flag: print("off")
else: print("on")
- Program C prints '18'.
- Program B prints 'true'.
- Program A prints 'done'.
- Program C prints 'on'.
- Program B prints 'a\nb'.
Explanation
Correct Answers
B:Running Program Bprints 'true'. The not operator inverts truthiness; it does not numerically negate an operand.
D:Running Program C prints 'on'. The not operator inverts truthiness; it does not numerically negate an operand.
Incorrect Answers
A:Program C does not produce '18'; its verified result is: Prints 'on'. The not operator inverts truthiness; it does not numerically negate an operand.
C:Program A does not produce 'done'; its verified result is:prints 'True'. The not operator inverts truthiness; it does not numerically negate an operand.
E:Program B does not produce 'a\nb'; its verified result is:prints 'True'. The not operator inverts truthiness; it does not numerically negate an operand.
Question 113
A learner is checking range stop is exclusive. What is the exact printed result or uncaught exception?print(list(range(4)))
- Prints '[0, 1, 2, 3]'
- Prints '[1, 2, 3]'
- Prints '[3, 2, 1, 0]'
- Prints '[0, 1, 2]'
Explanation
Correct Answer
A:The snippet prints '[0, 1, 2, 3]'. range excludes its stop argument, so range(n) runs from zero through n-1.
Incorrect Answers
B:This predicts that the snippet prints '[1, 2, 3]', but executing the displayed Python 3 code prints '[0, 1, 2, 3]'. range excludes its stop argument, so range(n) runs from zero through n-1.
C:This predicts that the snippet prints '[3, 2, 1, 0]', but executing the displayed Python 3 code prints '[0, 1, 2, 3]'. range excludes its stop argument, so range(n) runs from zero through n-1.
D:This predicts that the snippet prints '[0, 1, 2]', but executing the displayed Python 3 code prints '[0, 1, 2, 3]'. range excludes its stop argument, so range(n) runs from zero through n-1.
Question 114
A developer tests range stop is exclusive. The following code prints '[2, 3, 4]'. Which explanation best accounts for that observed behavior?print(list(range(2,5)))
- A negative range step decreases values and still excludes the stop bound.
- range excludes its stop argument, so range(n) runs from zero through n-1.
- Two separate if statements are tested independently; both can execute when both conditions are true.
- A for loop else clause does not run when a break ends the loop early.
Explanation
Correct Answer
B:This is the operative language rule for the code. It directly explains why the example prints '[2, 3, 4]'; the displayed behavior was independently reproduced by a Python 3 execution check.
Incorrect Answers
A:The range descending with negative step topic does not explain why the code prints '[2, 3, 4]'. The relevant Python rule is: range excludes its stop argument, so range(n) runs from zero through n-1.
C:The independent if branches topic does not explain why the code prints '[2, 3, 4]'. The relevant Python rule is: range excludes its stop argument, so range(n) runs from zero through n-1.
D:The for else suppressed by break topic does not explain why the code prints '[2, 3, 4]'. The relevant Python rule is: range excludes its stop argument, so range(n) runs from zero through n-1.
Question 115
A learner is checking range stop is exclusive. After this modification, what does Python 3 actually do?print(len(range(7)))
- Prints '6'
- Prints '8'
- Prints '9'
- Prints '7'
Explanation
Correct Answer
D:The snippet prints '7'. range excludes its stop argument, so range(n) runs from zero through n-1.
Incorrect Answers
A:This predicts that the snippet prints '6', but executing the displayed Python 3 code prints '7'. range excludes its stop argument, so range(n) runs from zero through n-1.
B:This predicts that the snippet prints '8', but executing the displayed Python 3 code prints '7'. range excludes its stop argument, so range(n) runs from zero through n-1.
C:This predicts that the snippet prints '9', but executing the displayed Python 3 code prints '7'. range excludes its stop argument, so range(n) runs from zero through n-1.
Question 116
During a review of range stop is exclusive, three independent Python 3 fragments are shown. Which TWO statements accurately describe their behavior? (Choose TWO.)Program A:
print(list(range(2,5)))
Program B:
print(len(range(7)))
Program C:
print(5 in range(5))
- Program A prints 'small odd'.
- Program C prints 'empty'.
- Program B prints '6'.
- Program B prints '7'.
- Program C prints 'false'.
Explanation
Correct Answers
D:Running Program B prints '7'. range excludes its stop argument, so range(n) runs from zero through n-1.
E:Running Program C prints 'false'. range excludes its stop argument, so range(n) runs from zero through n-1.
Incorrect Answers
A:Program A does not produce 'small odd'; its verified result is: Prints '[2, 3, 4]'. range excludes its stop argument, so range(n) runs from zero through n-1.
B:Program C does not produce 'empty'; its verified result is: Prints 'False'. range excludes its stop argument, so range(n) runs from zero through n-1.
C:Program B does not produce '6'; its verified result is: Prints '7'. range excludes its stop argument, so range(n) runs from zero through n-1.
Question 117
A learner is checking range with positive step. What is the exact printed result or uncaught exception?print(list(range(1,10,3)))
- Prints '[7, 4, 1]'
- Prints '[1, 4]'
- Prints '[1, 4, 7]'
- Prints '[4, 7]'
Explanation
Correct Answer
C:The snippet prints '[1, 4, 7]'. The third range argument controls the step, and the stop endpoint remains excluded.
Incorrect Answers
A:This predicts that the snippet prints '[7, 4, 1]', but executing the displayed Python 3 code prints '[1, 4, 7]'. The third range argument controls the step, and the stop endpoint remains excluded.
B:This predicts that the snippet prints '[1, 4]', but executing the displayed Python 3 code prints '[1, 4, 7]'. The third range argument controls the step, and the stop endpoint remains excluded.
D:This predicts that the snippet prints '[4, 7]', but executing the displayed Python 3 code prints '[1, 4, 7]'. The third range argument controls the step, and the stop endpoint remains excluded.
Question 118
A developer tests range with positive step. The following code prints '[0, 2, 4, 6]'. Which explanation best accounts for that observed behavior?print(list(range(0,8,2)))
- A Python for loop target remains bound to the last visited value after a nonempty loop.
- continue inside an inner loop skips one inner iteration while both loops otherwise proceed.
- The third range argument controls the step, and the stop endpoint remains excluded.
- Two separate if statements are tested independently; both can execute when both conditions are true.
Explanation
Correct Answer
C:This is the operative language rule for the code. It directly explains why the example prints '[0, 2, 4, 6]'; the displayed behavior was independently reproduced by a Python 3 execution check.
Incorrect Answers
A:The loop index persists after normal completion topic does not explain why the code prints '[0, 2, 4, 6]'. The relevant Python rule is: The third range argument controls the step, and the stop endpoint remains excluded.
B:The nested loop with conditional inner skip topic does not explain why the code prints '[0, 2, 4, 6]'. The relevant Python rule is: The third range argument controls the step, and the stop endpoint remains excluded.
D:The independent if branches topic does not explain why the code prints '[0, 2, 4, 6]'. The relevant Python rule is: The third range argument controls the step, and the stop endpoint remains excluded.
Question 119
A learner is checking range with positive step. After this modification, what does Python 3 actually do?print(sum(range(2,11,4)))
- Prints '18'
- Prints '19'
- Prints '17'
- Prints '20'
Explanation
Correct Answer
A:The snippet prints '18'. The third range argument controls the step, and the stop endpoint remains excluded.
Incorrect Answers
B:This predicts that the snippet prints '19', but executing the displayed Python 3 code prints '18'. The third range argument controls the step, and the stop endpoint remains excluded.
C:This predicts that the snippet prints '17', but executing the displayed Python 3 code prints '18'. The third range argument controls the step, and the stop endpoint remains excluded.
D:This predicts that the snippet prints '20', but executing the displayed Python 3 code prints '18'. The third range argument controls the step, and the stop endpoint remains excluded.
Question 120
During a review of range with positive step, three independent Python 3 fragments are shown. Which TWO statements accurately describe their behavior? (Choose TWO.)Program A:
print(list(range(0,8,2)))
Program B:
print(sum(range(2,11,4)))
Program C:
print(list(range(3,3,2)))
- Program B prints '18'.
- Program B prints '10'.
- Program C prints '[]'.
- Program A prints "['aa', 'bb']".
- Program C prints '18'.
Explanation
Correct Answers
A:Running Program B prints '18'. The third range argument controls the step, and the stop endpoint remains excluded.
C:Running Program C prints '[]'. The third range argument controls the step, and the stop endpoint remains excluded.
Incorrect Answers
B:Program B does not produce '10'; its verified result is: Prints '18'. The third range argument controls the step, and the stop endpoint remains excluded.
D:Program A does not produce "['aa', 'bb']"; its verified result is: Prints '[0, 2, 4, 6]'. The third range argument controls the step, and the stop endpoint remains excluded.
E:Program C does not produce '18'; its verified result is: Prints '[]'. The third range argument controls the step, and the stop endpoint remains excluded.
PCEP - Certified Entry-Level Python Programmer (PCEP-30-02) Practice Tests