100% Latest & Updated Python Institute PCEP-30-02 Practice Test Questions, Exam Dumps & Verified Answers!
30 Days Free Updates, Instant Download!
Question 90
A developer tests and conditions require both predicates. The following code prints 'middle'. Which explanation best accounts for that observed behavior?score=84
if score>=70 and score<90: print("middle")
else: print("other")
- A break inside the inner loop ends only that inner loop; the enclosing outer loop continues.
- A negative range step decreases values and still excludes the stop bound.
- continue skips the remaining body of the current iteration but does not end the whole loop.
- A conjunction using and is true only when both of its conditions are truthy.
Explanation
Correct Answer
D:This is the operative language rule for the code. It directly explains why the example prints 'middle'; the displayed behavior was independently reproduced by a Python 3 execution check.
Incorrect Answers
A:The break in a nested inner loop topic does not explain why the code prints 'middle'. The relevant Python rule is: A conjunction using and is true only when both of its conditions are truthy.
B:The range descending with negative step topic does not explain why the code prints 'middle'. The relevant Python rule is: A conjunction using and is true only when both of its conditions are truthy.
C:The continue skips the rest of one loop pass topic does not explain why the code prints 'middle'. The relevant Python rule is: A conjunction using and is true only when both of its conditions are truthy.
Question 91
A learner is checking and conditions require both predicates. After this modification, what does Python 3 actually do?n=8
if n>3 and n%3==0: print("match")
else: print("miss")
- Prints 'mis'
- Prints 'miss'
- Prints 'ssim'
- Prints 'miss?'
Explanation
Correct Answer
B:The snippet prints 'miss'. A conjunction using and is true only when both of its conditions are truthy.
Incorrect Answers
A:This predicts that the snippet prints 'mis', but executing the displayed Python 3 code prints 'miss'. A conjunction using and is true only when both of its conditions are truthy.
C:This predicts that the snippet prints 'ssim', but executing the displayed Python 3 code prints 'miss'. A conjunction using and is true only when both of its conditions are truthy.
D:This predicts that the snippet prints 'miss?', but executing the displayed Python 3 code prints 'miss'. A conjunction using and is true only when both of its conditions are truthy.
Question 92
A learner is checking and conditions require both predicates. Which final result follows from this separate test?x=0
if x and 10//x: print("yes")
else: print("no")
- Prints 'no'
- Prints 'on'
- Prints 'no?'
- Prints 'n'
Explanation
Correct Answer
A:The snippet prints 'no'. A conjunction using and is true only when both of its conditions are truthy.
Incorrect Answers
B:This predicts that the snippet prints 'on', but executing the displayed Python 3 code prints 'no'. A conjunction using and is true only when both of its conditions are truthy.
C:This predicts that the snippet prints 'no?', but executing the displayed Python 3 code prints 'no'. A conjunction using and is true only when both of its conditions are truthy.
D:This predicts that the snippet prints 'n', but executing the displayed Python 3 code prints 'no'. A conjunction using and is true only when both of its conditions are truthy.
Question 93
A learner is checking or branch accepts either condition. What is the exact printed result or uncaught exception?is_admin=False
is_owner=True
if is_admin or is_owner: print("allowed")
- Prints 'allowe'
- Prints 'allowed'
- Prints 'allowed?'
- Prints 'dewolla'
Explanation
Correct Answer
B:The snippet prints 'allowed'. A disjunction using or is true if either condition is true, including when the other is false.
Incorrect Answers
A:This predicts that the snippet prints 'allowe', but executing the displayed Python 3 code prints 'allowed'. A disjunction using or is true if either condition is true, including when the other is false.
C:This predicts that the snippet prints 'allowed?', but executing the displayed Python 3 code prints 'allowed'. A disjunction using or is true if either condition is true, including when the other is false.
D:This predicts that the snippet prints 'dewolla', but executing the displayed Python 3 code prints 'allowed'. A disjunction using or is true if either condition is true, including when the other is false.
Question 94
A developer tests or branch accepts either condition. The following code prints 'divisible'. Which explanation best accounts for that observed behavior?n=15
if n%2==0 or n%5==0: print("divisible")
- The in operator tests membership in a sequence or collection, not positional arithmetic equality.
- A break inside the inner loop ends only that inner loop; the enclosing outer loop continues.
- A disjunction using or is true if either condition is true, including when the other is false.
- A for loop iterating over a string yields one-character strings in left-to-right order.
Explanation
Correct Answer
C:This is the operative language rule for the code. It directly explains why the example prints 'divisible'; the displayed behavior was independently reproduced by a Python 3 execution check.
Incorrect Answers
A:The membership-based conditional topic does not explain why the code prints 'divisible'. The relevant Python rule is: A disjunction using or is true if either condition is true, including when the other is false.
B:The break in a nested inner loop topic does not explain why the code prints 'divisible'. The relevant Python rule is: A disjunction using or is true if either condition is true, including when the other is false.
D:The iteration over string characters topic does not explain why the code prints 'divisible'. The relevant Python rule is: A disjunction using or is true if either condition is true, including when the other is false.
Question 95
A learner is checking or branch accepts either condition. After this modification, what does Python 3 actually do?word=""
if word or len(word)>3: print("nonempty")
else: print("empty")
- Prints 'ytpme'
- Prints 'empt'
- Prints 'empty'
- Prints 'empty?'
Explanation
Correct Answer
C:The snippet prints 'empty'. A disjunction using or is true if either condition is true, including when the other is false.
Incorrect Answers
A:This predicts that the snippet prints 'ytpme', but executing the displayed Python 3 code prints 'empty'. A disjunction using or is true if either condition is true, including when the other is false.
B:This predicts that the snippet prints 'empt', but executing the displayed Python 3 code prints 'empty'. A disjunction using or is true if either condition is true, including when the other is false.
D:This predicts that the snippet prints 'empty?', but executing the displayed Python 3 code prints 'empty'. A disjunction using or is true if either condition is true, including when the other is false.
Question 96
During a review of or branch accepts either condition, three independent Python 3 fragments are shown. Which TWO statements accurately describe their behavior? (Choose TWO.)Program A:
n=15
if n%2==0 or n%5==0: print("divisible")
Program B:
word=""
if word or len(word)>3: print("nonempty")
else: print("empty")
Program C:
x=6
if x<0 or x>=6: print("edge")
else: print("inside")
- Program C prints 'none'.
- Program A prints 'even high'.
- Program C prints 'edge'.
- Program B prints 'large'.
- Program B prints 'empty'.
Explanation
Correct Answers
C:Running Program C prints 'edge'. A disjunction using or is true if either condition is true, including when the other is false.
E:Running Program B prints 'empty'. A disjunction using or is true if either condition is true, including when the other is false.
Incorrect Answers
A:Program C does not produce 'none'; its verified result is: Prints 'edge'. A disjunction using or is true if either condition is true, including when the other is false.
B:Program A does not produce 'even high'; its verified result is: Prints 'divisible'. A disjunction using or is true if either condition is true, including when the other is false.
D:Program B does not produce 'large'; its verified result is: Prints 'empty'. A disjunction using or is true if either condition is true, including when the other is false.
Question 97
A learner is checking chained inequalities in conditions. What is the exact printed result or uncaught exception?x=6
print(2<x<10)
- Prints '1'
- Prints 'True'
- Prints '0'
- Prints 'False'
Explanation
Correct Answer
B:The snippetprints 'true'. A chained comparison tests both adjacent relationships, avoiding any need to repeat the middle expression.
Incorrect Answers
A:This predicts that the snippet prints '1', but executing the displayed Python 3 codeprints 'true'. A chained comparison tests both adjacent relationships, avoiding any need to repeat the middle expression.
C:This predicts that the snippet prints '0', but executing the displayed Python 3 codeprints 'true'. A chained comparison tests both adjacent relationships, avoiding any need to repeat the middle expression.
D:This predicts that the snippet prints 'false', but executing the displayed Python 3 codeprints 'true'. A chained comparison tests both adjacent relationships, avoiding any need to repeat the middle expression.
Question 98
A developer tests chained inequalities in conditions. The following code prints 'false'. Which explanation best accounts for that observed behavior?x=10
print(2<x<10)
- break exits its nearest enclosing loop immediately, without executing subsequent iterations.
- An inner if statement runs only when its containing outer condition is true.
- A for loop visits each iterable element and can update a running accumulator on each pass.
- A chained comparison tests both adjacent relationships, avoiding any need to repeat the middle expression.
Explanation
Correct Answer
D: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
A:The break terminates the nearest loop topic does not explain why the code prints 'false'. The relevant Python rule is: A chained comparison tests both adjacent relationships, avoiding any need to repeat the middle expression.
B:The nested condition dependencies topic does not explain why the code prints 'false'. The relevant Python rule is: A chained comparison tests both adjacent relationships, avoiding any need to repeat the middle expression.
C:The for loop accumulating a sum topic does not explain why the code prints 'false'. The relevant Python rule is: A chained comparison tests both adjacent relationships, avoiding any need to repeat the middle expression.
Question 99
A learner is checking chained inequalities in conditions. After this modification, what does Python 3 actually do?n=-2
print(-3<=n<=0)
- Prints '0'
- Prints 'True'
- Prints 'False'
- Prints '1'
Explanation
Correct Answer
B:The snippetprints 'true'. A chained comparison tests both adjacent relationships, avoiding any need to repeat the middle expression.
Incorrect Answers
A:This predicts that the snippet prints '0', but executing the displayed Python 3 codeprints 'true'. A chained comparison tests both adjacent relationships, avoiding any need to repeat the middle expression.
C:This predicts that the snippet prints 'false', but executing the displayed Python 3 codeprints 'true'. A chained comparison tests both adjacent relationships, avoiding any need to repeat the middle expression.
D:This predicts that the snippet prints '1', but executing the displayed Python 3 codeprints 'true'. A chained comparison tests both adjacent relationships, avoiding any need to repeat the middle expression.
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.
PCEP - Certified Entry-Level Python Programmer (PCEP-30-02) Practice Tests