100% Latest & Updated Python Institute PCEP-30-02 Practice Test Questions, Exam Dumps & Verified Answers!
30 Days Free Updates, Instant Download!
Question 70
A developer tests input strings and explicit conversion. The following code prints '15'. Which explanation best accounts for that observed behavior?v=input()
print(int(v)+3)
- Escape sequences such as \n and \t represent control characters inside strings rather than literal backslash-letter pairs.
- Python statements execute in source order; earlier assignments and prints take effect before later ones.
- A # outside a string begins a comment and does not change the preceding executable expression.
- input returns a string; numeric calculations require explicit int or float conversion when text is provided.
Explanation
Correct Answer
D:This is the operative language rule for the code. It directly explains why the example prints '15'; the displayed behavior was independently reproduced by a Python 3 execution check.
Incorrect Answers
A:The escaped newline and tab characters topic does not explain why the code prints '15'. The relevant Python rule is: input returns a string; numeric calculations require explicit int or float conversion when text is provided.
B:The sequential interpreter execution topic does not explain why the code prints '15'. The relevant Python rule is: input returns a string; numeric calculations require explicit int or float conversion when text is provided.
C:The comments and executable code topic does not explain why the code prints '15'. The relevant Python rule is: input returns a string; numeric calculations require explicit int or float conversion when text is provided.
Question 71
A learner is checking input strings and explicit conversion. After this modification, what does Python 3 actually do?v=input()
print(float(v)/4)
- Prints '5.0'
- Prints '2.0'
- Prints '4.0'
- Prints '3.0'
Explanation
Correct Answer
D:The snippet prints '3.0'. input returns a string; numeric calculations require explicit int or float conversion when text is provided.
Incorrect Answers
A:This predicts that the snippet prints '5.0', but executing the displayed Python 3 code prints '3.0'. input returns a string; numeric calculations require explicit int or float conversion when text is provided.
B:This predicts that the snippet prints '2.0', but executing the displayed Python 3 code prints '3.0'. input returns a string; numeric calculations require explicit int or float conversion when text is provided.
C:This predicts that the snippet prints '4.0', but executing the displayed Python 3 code prints '3.0'. input returns a string; numeric calculations require explicit int or float conversion when text is provided.
Question 72
During a review of input strings and explicit conversion, three independent Python 3 fragments are shown. Which THREE statements accurately describe their behavior? (Choose THREE.)Program A:
v=input()
print(int(v)+3)
Program B:
v=input()
print(float(v)/4)
Program C:
v=input()
print(v*2)
- Program B prints '1.2'.
- Program A prints '81'.
- Program A prints '15'.
- Program C prints '3\n4'.
- Program B prints '3.0'.
- Program C prints '1212'.
Explanation
Correct Answers
C:Running Program A prints '15'. input returns a string; numeric calculations require explicit int or float conversion when text is provided.
E:Running Program B prints '3.0'. input returns a string; numeric calculations require explicit int or float conversion when text is provided.
F:Running Program C prints '1212'. input returns a string; numeric calculations require explicit int or float conversion when text is provided.
Incorrect Answers
A:Program B does not produce '1.2'; its verified result is: Prints '3.0'. input returns a string; numeric calculations require explicit int or float conversion when text is provided.
B:Program A does not produce '81'; its verified result is: Prints '15'. input returns a string; numeric calculations require explicit int or float conversion when text is provided.
D:Program C does not produce '3\n4'; its verified result is: Prints '1212'. input returns a string; numeric calculations require explicit int or float conversion when text is provided.
Question 73
A learner is checking ordered if elif branch selection. What is the exact printed result or uncaught exception?n=12
if n>5: print("large")
elif n>10: print("huge")
else: print("small")
- Prints 'large?'
- Prints 'large'
- Prints 'larg'
- Prints 'egral'
Explanation
Correct Answer
B:The snippet prints 'large'. In an if/elif chain, Python executes the first true branch and skips all later branches.
Incorrect Answers
A:This predicts that the snippet prints 'large?', but executing the displayed Python 3 code prints 'large'. In an if/elif chain, Python executes the first true branch and skips all later branches.
C:This predicts that the snippet prints 'larg', but executing the displayed Python 3 code prints 'large'. In an if/elif chain, Python executes the first true branch and skips all later branches.
D:This predicts that the snippet prints 'egral', but executing the displayed Python 3 code prints 'large'. In an if/elif chain, Python executes the first true branch and skips all later branches.
Question 74
A developer tests ordered if elif branch selection. The following code prints 'b'. Which explanation best accounts for that observed behavior?score=74
if score>=90: print("A")
elif score>=70: print("B")
else: print("C")
- In an if/elif chain, Python executes the first true branch and skips all later branches.
- A for loop iterating over a string yields one-character strings in left-to-right order.
- A chained comparison tests both adjacent relationships, avoiding any need to repeat the middle expression.
- Empty strings and containers are falsy; nonempty ones are truthy in an if condition.
Explanation
Correct Answer
A:This is the operative language rule for the code. It directly explains why the example prints 'b'; the displayed behavior was independently reproduced by a Python 3 execution check.
Incorrect Answers
B:The iteration over string characters topic does not explain why the code prints 'b'. The relevant Python rule is: In an if/elif chain, Python executes the first true branch and skips all later branches.
C:The chained inequalities in conditions topic does not explain why the code prints 'b'. The relevant Python rule is: In an if/elif chain, Python executes the first true branch and skips all later branches.
D:The empty container truthiness topic does not explain why the code prints 'b'. The relevant Python rule is: In an if/elif chain, Python executes the first true branch and skips all later branches.
Question 75
A learner is checking ordered if elif branch selection. After this modification, what does Python 3 actually do?n=-2
if n>0: print("pos")
elif n<0: print("neg")
else: print("zero")
- Prints 'neg?'
- Prints 'neg'
- Prints 'gen'
- Prints 'ne'
Explanation
Correct Answer
B:The snippet prints 'neg'. In an if/elif chain, Python executes the first true branch and skips all later branches.
Incorrect Answers
A:This predicts that the snippet prints 'neg?', but executing the displayed Python 3 code prints 'neg'. In an if/elif chain, Python executes the first true branch and skips all later branches.
C:This predicts that the snippet prints 'gen', but executing the displayed Python 3 code prints 'neg'. In an if/elif chain, Python executes the first true branch and skips all later branches.
D:This predicts that the snippet prints 'ne', but executing the displayed Python 3 code prints 'neg'. In an if/elif chain, Python executes the first true branch and skips all later branches.
Question 76
A learner is checking ordered if elif branch selection. Which final result follows from this separate test?x=5
if x%2==0: print("even")
elif x<10: print("small odd")
else: print("other")
- Prints 'small odd?'
- Prints 'small odd'
- Prints 'ddo llams'
- Prints 'small od'
Explanation
Correct Answer
B:The snippet prints 'small odd'. In an if/elif chain, Python executes the first true branch and skips all later branches.
Incorrect Answers
A:This predicts that the snippet prints 'small odd?', but executing the displayed Python 3 code prints 'small odd'. In an if/elif chain, Python executes the first true branch and skips all later branches.
C:This predicts that the snippet prints 'ddo llams', but executing the displayed Python 3 code prints 'small odd'. In an if/elif chain, Python executes the first true branch and skips all later branches.
D:This predicts that the snippet prints 'small od', but executing the displayed Python 3 code prints 'small odd'. In an if/elif chain, Python executes the first true branch and skips all later branches.
Question 77
A learner is checking independent if branches. What is the exact printed result or uncaught exception?x=9
if x>5: print("A")
if x<12: print("B")
- Prints 'B'
- Prints 'A\nB'
- Prints 'B\nA'
- Prints 'A'
Explanation
Correct Answer
B:The snippet prints 'a\nb'. Two separate if statements are tested independently; both can execute when both conditions are true.
Incorrect Answers
A:This predicts that the snippet prints 'b', but executing the displayed Python 3 code prints 'a\nb'. Two separate if statements are tested independently; both can execute when both conditions are true.
C:This predicts that the snippet prints 'b\na', but executing the displayed Python 3 code prints 'a\nb'. Two separate if statements are tested independently; both can execute when both conditions are true.
D:This predicts that the snippet prints 'a', but executing the displayed Python 3 code prints 'a\nb'. Two separate if statements are tested independently; both can execute when both conditions are true.
Question 78
A developer tests independent if branches. The following code prints 'even\nthree'. Which explanation best accounts for that observed behavior?n=6
if n%2==0: print("even")
if n%3==0: print("three")
- A Python for loop target remains bound to the last visited value after a nonempty loop.
- 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.
- The third range argument controls the step, and the stop endpoint remains excluded.
Explanation
Correct Answer
B:This is the operative language rule for the code. It directly explains why the example prints 'even\nthree'; 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 'even\nthree'. The relevant Python rule is: Two separate if statements are tested independently; both can execute when both conditions are true.
C:The for else suppressed by break topic does not explain why the code prints 'even\nthree'. The relevant Python rule is: Two separate if statements are tested independently; both can execute when both conditions are true.
D:The range with positive step topic does not explain why the code prints 'even\nthree'. The relevant Python rule is: Two separate if statements are tested independently; both can execute when both conditions are true.
Question 79
A learner is checking independent if branches. After this modification, what does Python 3 actually do?n=10
if n<0: print("negative")
if n>=10: print("two digits")
- Prints 'stigid owt'
- Prints 'two digits?'
- Prints 'two digit'
- Prints 'two digits'
Explanation
Correct Answer
D:The snippet prints 'two digits'. Two separate if statements are tested independently; both can execute when both conditions are true.
Incorrect Answers
A:This predicts that the snippet prints 'stigid owt', but executing the displayed Python 3 code prints 'two digits'. Two separate if statements are tested independently; both can execute when both conditions are true.
B:This predicts that the snippet prints 'two digits?', but executing the displayed Python 3 code prints 'two digits'. Two separate if statements are tested independently; both can execute when both conditions are true.
C:This predicts that the snippet prints 'two digit', but executing the displayed Python 3 code prints 'two digits'. Two separate if statements are tested independently; both can execute when both conditions are true.
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.
PCEP - Certified Entry-Level Python Programmer (PCEP-30-02) Practice Tests