100% Latest & Updated Python Institute PCEP-30-02 Practice Test Questions, Exam Dumps & Verified Answers!
30 Days Free Updates, Instant Download!
Question 100
During a review of chained inequalities in conditions, three independent Python 3 fragments are shown. Which TWO statements accurately describe their behavior? (Choose TWO.)Program A:
x=10
print(2<x<10)
Program B:
n=-2
print(-3<=n<=0)
Program C:
x=3
print(3<=x<6)
- Program B prints 'true'.
- Program C prints 'true'.
- Program B prints 'miss'.
- Program A prints 'empty'.
- Program C prints 'done'.
Explanation
Correct Answers
A:Running Program Bprints 'true'. A chained comparison tests both adjacent relationships, avoiding any need to repeat the middle expression.
B:Running Program Cprints 'true'. A chained comparison tests both adjacent relationships, avoiding any need to repeat the middle expression.
Incorrect Answers
C:Program B does not produce 'miss'; its verified result is:prints 'True'. A chained comparison tests both adjacent relationships, avoiding any need to repeat the middle expression.
D:Program A does not produce 'empty'; its verified result is: Prints 'False'. A chained comparison tests both adjacent relationships, avoiding any need to repeat the middle expression.
E:Program C does not produce 'done'; its verified result is:prints 'True'. A chained comparison tests both adjacent relationships, avoiding any need to repeat the middle expression.
Question 101
A learner is checking membership-based conditional. What is the exact printed result or uncaught exception?letters="abcd"
print("bc" in letters)
- Prints '1'
- Prints 'False'
- Prints '0'
- Prints 'True'
Explanation
Correct Answer
D:The snippetprints 'true'. The in operator tests membership in a sequence or collection, not positional arithmetic equality.
Incorrect Answers
A:This predicts that the snippet prints '1', but executing the displayed Python 3 codeprints 'true'. The in operator tests membership in a sequence or collection, not positional arithmetic equality.
B:This predicts that the snippet prints 'false', but executing the displayed Python 3 codeprints 'true'. The in operator tests membership in a sequence or collection, not positional arithmetic equality.
C:This predicts that the snippet prints '0', but executing the displayed Python 3 codeprints 'true'. The in operator tests membership in a sequence or collection, not positional arithmetic equality.
Question 102
A developer tests membership-based conditional. The following code prints 'false'. Which explanation best accounts for that observed behavior?allowed=[2,4,6]
print(5 in allowed)
- The in operator tests membership in a sequence or collection, not positional arithmetic equality.
- continue skips the remaining body of the current iteration but does not end the whole loop.
- A negative range step decreases values and still excludes the stop bound.
- A for loop visits each iterable element and can update a running accumulator on each pass.
Explanation
Correct Answer
A:This is the operative language rule for the code. It directly explains why the example prints 'false'; the displayed behavior was independently reproduced by a Python 3 execution check.
Incorrect Answers
B:The continue skips the rest of one loop pass topic does not explain why the code prints 'false'. The relevant Python rule is: The in operator tests membership in a sequence or collection, not positional arithmetic equality.
C:The range descending with negative step topic does not explain why the code prints 'false'. The relevant Python rule is: The in operator tests membership in a sequence or collection, not positional arithmetic equality.
D:The for loop accumulating a sum topic does not explain why the code prints 'false'. The relevant Python rule is: The in operator tests membership in a sequence or collection, not positional arithmetic equality.
Question 103
A learner is checking membership-based conditional. After this modification, what does Python 3 actually do?code="ZX"
print("x" not in code)
- Prints 'False'
- Prints 'True'
- Prints '1'
- Prints '0'
Explanation
Correct Answer
B:The snippetprints 'true'. The in operator tests membership in a sequence or collection, not positional arithmetic equality.
Incorrect Answers
A:This predicts that the snippet prints 'false', but executing the displayed Python 3 codeprints 'true'. The in operator tests membership in a sequence or collection, not positional arithmetic equality.
C:This predicts that the snippet prints '1', but executing the displayed Python 3 codeprints 'true'. The in operator tests membership in a sequence or collection, not positional arithmetic equality.
D:This predicts that the snippet prints '0', but executing the displayed Python 3 codeprints 'true'. The in operator tests membership in a sequence or collection, not positional arithmetic equality.
Question 104
During a review of membership-based conditional, three independent Python 3 fragments are shown. Which TWO statements accurately describe their behavior? (Choose TWO.)Program A:
allowed=[2,4,6]
print(5 in allowed)
Program B:
code="ZX"
print("x" not in code)
Program C:
names=("ana","bea")
print("bea" in names)
- Program A prints 'equal'.
- Program C prints 'edge'.
- Program C prints 'true'.
- Program B prints 'true'.
- Program B prints 'a\nb'.
Explanation
Correct Answers
C:Running Program Cprints 'true'. The in operator tests membership in a sequence or collection, not positional arithmetic equality.
D:Running Program Bprints 'true'. The in operator tests membership in a sequence or collection, not positional arithmetic equality.
Incorrect Answers
A:Program A does not produce 'equal'; its verified result is: Prints 'False'. The in operator tests membership in a sequence or collection, not positional arithmetic equality.
B:Program C does not produce 'edge'; its verified result is:prints 'True'. The in operator tests membership in a sequence or collection, not positional arithmetic equality.
E:Program B does not produce 'a\nb'; its verified result is:prints 'True'. The in operator tests membership in a sequence or collection, not positional arithmetic equality.
Question 105
A learner is checking empty container truthiness. What is the exact printed result or uncaught exception?items=[]
if items: print("items")
else: print("empty")
- Prints 'empt'
- Prints 'empty'
- Prints 'empty?'
- Prints 'ytpme'
Explanation
Correct Answer
B:The snippet prints 'empty'. Empty strings and containers are falsy; nonempty ones are truthy in an if condition.
Incorrect Answers
A:This predicts that the snippet prints 'empt', but executing the displayed Python 3 code prints 'empty'. Empty strings and containers are falsy; nonempty ones are truthy in an if condition.
C:This predicts that the snippet prints 'empty?', but executing the displayed Python 3 code prints 'empty'. Empty strings and containers are falsy; nonempty ones are truthy in an if condition.
D:This predicts that the snippet prints 'ytpme', but executing the displayed Python 3 code prints 'empty'. Empty strings and containers are falsy; nonempty ones are truthy in an if condition.
Question 106
A developer tests empty container truthiness. The following code prints 'nonempty'. Which explanation best accounts for that observed behavior?s="0"
if s: print("nonempty")
else: print("empty")
- Empty strings and containers are falsy; nonempty ones are truthy in an if condition.
- An inner if statement runs only when its containing outer condition is true.
- A disjunction using or is true if either condition is true, including when the other is false.
- A break inside the inner loop ends only that inner loop; the enclosing outer loop continues.
Explanation
Correct Answer
A:This is the operative language rule for the code. It directly explains why the example prints 'nonempty'; the displayed behavior was independently reproduced by a Python 3 execution check.
Incorrect Answers
B:The nested condition dependencies topic does not explain why the code prints 'nonempty'. The relevant Python rule is: Empty strings and containers are falsy; nonempty ones are truthy in an if condition.
C:The or branch accepts either condition topic does not explain why the code prints 'nonempty'. The relevant Python rule is: Empty strings and containers are falsy; nonempty ones are truthy in an if condition.
D:The break in a nested inner loop topic does not explain why the code prints 'nonempty'. The relevant Python rule is: Empty strings and containers are falsy; nonempty ones are truthy in an if condition.
Question 107
A learner is checking empty container truthiness. After this modification, what does Python 3 actually do?t=()
print(bool(t))
- Prints 'True'
- Prints 'False'
- Prints '1'
- Prints '0'
Explanation
Correct Answer
B:The snippet prints 'false'. Empty strings and containers are falsy; nonempty ones are truthy in an if condition.
Incorrect Answers
A:This predicts that the snippetprints 'true', but executing the displayed Python 3 code prints 'false'. Empty strings and containers are falsy; nonempty ones are truthy in an if condition.
C:This predicts that the snippet prints '1', but executing the displayed Python 3 code prints 'false'. Empty strings and containers are falsy; nonempty ones are truthy in an if condition.
D:This predicts that the snippet prints '0', but executing the displayed Python 3 code prints 'false'. Empty strings and containers are falsy; nonempty ones are truthy in an if condition.
Question 108
During a review of empty container truthiness, three independent Python 3 fragments are shown. Which TWO statements accurately describe their behavior? (Choose TWO.)Program A:
s="0"
if s: print("nonempty")
else: print("empty")
Program B:
t=()
print(bool(t))
Program C:
data=[0]
print(bool(data))
- Program B prints 'large'.
- Program C prints 'true'.
- Program C prints 'edge'.
- Program B prints 'false'.
- Program A prints '012 done'.
Explanation
Correct Answers
B:Running Program Cprints 'true'. Empty strings and containers are falsy; nonempty ones are truthy in an if condition.
D:Running Program B prints 'false'. Empty strings and containers are falsy; nonempty ones are truthy in an if condition.
Incorrect Answers
A:Program B does not produce 'large'; its verified result is: Prints 'False'. Empty strings and containers are falsy; nonempty ones are truthy in an if condition.
C:Program C does not produce 'edge'; its verified result is:prints 'True'. Empty strings and containers are falsy; nonempty ones are truthy in an if condition.
E:Program A does not produce '012 done'; its verified result is: Prints 'nonempty'. Empty strings and containers are falsy; nonempty ones are truthy in an if condition.
Question 109
A learner is checking not reverses Boolean conditions. What is the exact printed result or uncaught exception?done=False
print(not done)
- Prints '0'
- Prints 'False'
- Prints 'True'
- Prints '1'
Explanation
Correct Answer
C:The snippetprints 'true'. The not operator inverts truthiness; it does not numerically negate an operand.
Incorrect Answers
A: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.
B: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 '1', but executing the displayed Python 3 codeprints 'true'. The not operator inverts truthiness; it does not numerically negate an operand.
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.
PCEP - Certified Entry-Level Python Programmer (PCEP-30-02) Practice Tests