100% Latest & Updated Python Institute PCEP-30-02 Practice Test Questions, Exam Dumps & Verified Answers!
30 Days Free Updates, Instant Download!
Question 80
A learner is checking independent if branches. Which final result follows from this separate test?x=1
if x>2: print("hi")
if x<=2: print("low")
- Prints 'low?'
- Prints 'lo'
- Prints 'low'
- Prints 'wol'
Explanation
Correct Answer
C:The snippet prints 'low'. Two separate if statements are tested independently; both can execute when both conditions are true.
Incorrect Answers
A:This predicts that the snippet prints 'low?', but executing the displayed Python 3 code prints 'low'. Two separate if statements are tested independently; both can execute when both conditions are true.
B:This predicts that the snippet prints 'lo', but executing the displayed Python 3 code prints 'low'. Two separate if statements are tested independently; both can execute when both conditions are true.
D:This predicts that the snippet prints 'wol', but executing the displayed Python 3 code prints 'low'. Two separate if statements are tested independently; both can execute when both conditions are true.
Question 81
A learner is checking nested condition dependencies. What is the exact printed result or uncaught exception?n=8
if n>5:
if n%2==0: print("even high")
- Prints 'hgih neve'
- Prints 'even high?'
- Prints 'even hig'
- Prints 'even high'
Explanation
Correct Answer
D:The snippet prints 'even high'. An inner if statement runs only when its containing outer condition is true.
Incorrect Answers
A:This predicts that the snippet prints 'hgih neve', but executing the displayed Python 3 code prints 'even high'. An inner if statement runs only when its containing outer condition is true.
B:This predicts that the snippet prints 'even high?', but executing the displayed Python 3 code prints 'even high'. An inner if statement runs only when its containing outer condition is true.
C:This predicts that the snippet prints 'even hig', but executing the displayed Python 3 code prints 'even high'. An inner if statement runs only when its containing outer condition is true.
Question 82
A developer tests nested condition dependencies. The following code prints 'done'. Which explanation best accounts for that observed behavior?n=3
if n>5:
if n%2: print("odd high")
print("done")
- A negative range step decreases values and still excludes the stop bound.
- A break inside the inner loop ends only that inner loop; the enclosing outer loop continues.
- A Python for loop target remains bound to the last visited value after a nonempty loop.
- An inner if statement runs only when its containing outer condition is true.
Explanation
Correct Answer
D:This is the operative language rule for the code. It directly explains why the example prints 'done'; 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 'done'. The relevant Python rule is: An inner if statement runs only when its containing outer condition is true.
B:The break in a nested inner loop topic does not explain why the code prints 'done'. The relevant Python rule is: An inner if statement runs only when its containing outer condition is true.
C:The loop index persists after normal completion topic does not explain why the code prints 'done'. The relevant Python rule is: An inner if statement runs only when its containing outer condition is true.
Question 83
A learner is checking nested condition dependencies. After this modification, what does Python 3 actually do?n=7
if n>5:
if n%2: print("odd high")
else: print("even high")
- Prints 'odd high?'
- Prints 'hgih ddo'
- Prints 'odd high'
- Prints 'odd hig'
Explanation
Correct Answer
C:The snippet prints 'odd high'. An inner if statement runs only when its containing outer condition is true.
Incorrect Answers
A:This predicts that the snippet prints 'odd high?', but executing the displayed Python 3 code prints 'odd high'. An inner if statement runs only when its containing outer condition is true.
B:This predicts that the snippet prints 'hgih ddo', but executing the displayed Python 3 code prints 'odd high'. An inner if statement runs only when its containing outer condition is true.
D:This predicts that the snippet prints 'odd hig', but executing the displayed Python 3 code prints 'odd high'. An inner if statement runs only when its containing outer condition is true.
Question 84
A learner is checking nested condition dependencies. Which final result follows from this separate test?n=-4
if n<0:
if abs(n)>3: print("far below")
- Prints 'far below?'
- Prints 'far below'
- Prints 'far belo'
- Prints 'woleb raf'
Explanation
Correct Answer
B:The snippet prints 'far below'. An inner if statement runs only when its containing outer condition is true.
Incorrect Answers
A:This predicts that the snippet prints 'far below?', but executing the displayed Python 3 code prints 'far below'. An inner if statement runs only when its containing outer condition is true.
C:This predicts that the snippet prints 'far belo', but executing the displayed Python 3 code prints 'far below'. An inner if statement runs only when its containing outer condition is true.
D:This predicts that the snippet prints 'woleb raf', but executing the displayed Python 3 code prints 'far below'. An inner if statement runs only when its containing outer condition is true.
Question 85
A learner is checking which else belongs to if. What is the exact printed result or uncaught exception?x=3
if x>0:
if x>5: print("big")
else: print("positive small")
- Prints 'positive smal'
- Prints 'positive small?'
- Prints 'positive small'
- Prints 'llams evitisop'
Explanation
Correct Answer
C:The snippet prints 'positive small'. An else block belongs to its indentation-level if; nested else is not automatically the outer else.
Incorrect Answers
A:This predicts that the snippet prints 'positive smal', but executing the displayed Python 3 code prints 'positive small'. An else block belongs to its indentation-level if; nested else is not automatically the outer else.
B:This predicts that the snippet prints 'positive small?', but executing the displayed Python 3 code prints 'positive small'. An else block belongs to its indentation-level if; nested else is not automatically the outer else.
D:This predicts that the snippet prints 'llams evitisop', but executing the displayed Python 3 code prints 'positive small'. An else block belongs to its indentation-level if; nested else is not automatically the outer else.
Question 86
A developer tests which else belongs to if. The following code prints 'nonpositive'. Which explanation best accounts for that observed behavior?x=-1
if x>0:
if x>5: print("big")
else: print("small")
else: print("nonpositive")
- continue skips the remaining body of the current iteration but does not end the whole loop.
- A while loop can run zero times when its condition is initially false.
- A disjunction using or is true if either condition is true, including when the other is false.
- An else block belongs to its indentation-level if; nested else is not automatically the outer else.
Explanation
Correct Answer
D:This is the operative language rule for the code. It directly explains why the example prints 'nonpositive'; the displayed behavior was independently reproduced by a Python 3 execution check.
Incorrect Answers
A:The continue skips the rest of one loop pass topic does not explain why the code prints 'nonpositive'. The relevant Python rule is: An else block belongs to its indentation-level if; nested else is not automatically the outer else.
B:The while condition checked before first iteration topic does not explain why the code prints 'nonpositive'. The relevant Python rule is: An else block belongs to its indentation-level if; nested else is not automatically the outer else.
C:The or branch accepts either condition topic does not explain why the code prints 'nonpositive'. The relevant Python rule is: An else block belongs to its indentation-level if; nested else is not automatically the outer else.
Question 87
A learner is checking which else belongs to if. After this modification, what does Python 3 actually do?x=5
if x>=5:
if x==5: print("equal")
else: print("below")
- Prints 'equal'
- Prints 'equa'
- Prints 'lauqe'
- Prints 'equal?'
Explanation
Correct Answer
A:The snippet prints 'equal'. An else block belongs to its indentation-level if; nested else is not automatically the outer else.
Incorrect Answers
B:This predicts that the snippet prints 'equa', but executing the displayed Python 3 code prints 'equal'. An else block belongs to its indentation-level if; nested else is not automatically the outer else.
C:This predicts that the snippet prints 'lauqe', but executing the displayed Python 3 code prints 'equal'. An else block belongs to its indentation-level if; nested else is not automatically the outer else.
D:This predicts that the snippet prints 'equal?', but executing the displayed Python 3 code prints 'equal'. An else block belongs to its indentation-level if; nested else is not automatically the outer else.
Question 88
A learner is checking which else belongs to if. Which final result follows from this separate test?x=1
if x>0:
if x<0: print("inner")
else: print("inner else")
- Prints 'esle renni'
- Prints 'inner else?'
- Prints 'inner els'
- Prints 'inner else'
Explanation
Correct Answer
D:The snippet prints 'inner else'. An else block belongs to its indentation-level if; nested else is not automatically the outer else.
Incorrect Answers
A:This predicts that the snippet prints 'esle renni', but executing the displayed Python 3 code prints 'inner else'. An else block belongs to its indentation-level if; nested else is not automatically the outer else.
B:This predicts that the snippet prints 'inner else?', but executing the displayed Python 3 code prints 'inner else'. An else block belongs to its indentation-level if; nested else is not automatically the outer else.
C:This predicts that the snippet prints 'inner els', but executing the displayed Python 3 code prints 'inner else'. An else block belongs to its indentation-level if; nested else is not automatically the outer else.
Question 89
A learner is checking and conditions require both predicates. What is the exact printed result or uncaught exception?age=20
member=True
if age>=18 and member: print("admit")
else: print("deny")
- Prints 'admit'
- Prints 'admi'
- Prints 'admit?'
- Prints 'timda'
Explanation
Correct Answer
A:The snippet prints 'admit'. A conjunction using and is true only when both of its conditions are truthy.
Incorrect Answers
B:This predicts that the snippet prints 'admi', but executing the displayed Python 3 code prints 'admit'. A conjunction using and is true only when both of its conditions are truthy.
C:This predicts that the snippet prints 'admit?', but executing the displayed Python 3 code prints 'admit'. A conjunction using and is true only when both of its conditions are truthy.
D:This predicts that the snippet prints 'timda', but executing the displayed Python 3 code prints 'admit'. A conjunction using and is true only when both of its conditions are truthy.
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.
PCEP - Certified Entry-Level Python Programmer (PCEP-30-02) Practice Tests