100% Latest & Updated Python Institute PCEP-30-02 Practice Test Questions, Exam Dumps & Verified Answers!
30 Days Free Updates, Instant Download!
Question 1
A learner is checking sequential interpreter execution. What is the exact printed result or uncaught exception?print("first")
print("second")
- Prints 'second\nfirst'
- Prints 'first\nsecond'
- Prints 'second'
- Prints 'first'
Explanation
Correct Answer
B:The snippet prints 'first\nsecond'. Python statements execute in source order; earlier assignments and prints take effect before later ones.
Incorrect Answers
A:This predicts that the snippet prints 'second\nfirst', but executing the displayed Python 3 code prints 'first\nsecond'. Python statements execute in source order; earlier assignments and prints take effect before later ones.
C:This predicts that the snippet prints 'second', but executing the displayed Python 3 code prints 'first\nsecond'. Python statements execute in source order; earlier assignments and prints take effect before later ones.
D:This predicts that the snippet prints 'first', but executing the displayed Python 3 code prints 'first\nsecond'. Python statements execute in source order; earlier assignments and prints take effect before later ones.
Question 2
A developer tests sequential interpreter execution. The following code prints '4\n9'. Which explanation best accounts for that observed behavior?x=4
print(x)
x=9
print(x)
- Multiplication and division bind before addition and subtraction unless parentheses override precedence.
- The and and or operators short-circuit and return operands, not necessarily Boolean objects.
- Prefix 0b, 0o and 0x specifies the base of an integer literal, and mixed-base arithmetic uses numeric values.
- Python statements execute in source order; earlier assignments and prints take effect before later ones.
Explanation
Correct Answer
D:This is the operative language rule for the code. It directly explains why the example prints '4\n9'; the displayed behavior was independently reproduced by a Python 3 execution check.
Incorrect Answers
A:The multiplication and addition precedence topic does not explain why the code prints '4\n9'. The relevant Python rule is: Python statements execute in source order; earlier assignments and prints take effect before later ones.
B:The short-circuit Boolean expressions topic does not explain why the code prints '4\n9'. The relevant Python rule is: Python statements execute in source order; earlier assignments and prints take effect before later ones.
C:The binary octal and hexadecimal integer literals topic does not explain why the code prints '4\n9'. The relevant Python rule is: Python statements execute in source order; earlier assignments and prints take effect before later ones.
Question 3
A learner is checking sequential interpreter execution. After this modification, what does Python 3 actually do?print(3)
print(3+1)
- Prints '4'
- Prints '3\n4'
- Prints '3'
- Prints '4\n3'
Explanation
Correct Answer
B:The snippet prints '3\n4'. Python statements execute in source order; earlier assignments and prints take effect before later ones.
Incorrect Answers
A:This predicts that the snippet prints '4', but executing the displayed Python 3 code prints '3\n4'. Python statements execute in source order; earlier assignments and prints take effect before later ones.
C:This predicts that the snippet prints '3', but executing the displayed Python 3 code prints '3\n4'. Python statements execute in source order; earlier assignments and prints take effect before later ones.
D:This predicts that the snippet prints '4\n3', but executing the displayed Python 3 code prints '3\n4'. Python statements execute in source order; earlier assignments and prints take effect before later ones.
Question 4
A learner is checking sequential interpreter execution. Which final result follows from this separate test?n=0
print(n)
n=n+2
print(n)
- Prints '2\n0'
- Prints '0'
- Prints '0\n2'
- Prints '2'
Explanation
Correct Answer
C:The snippet prints '0\n2'. Python statements execute in source order; earlier assignments and prints take effect before later ones.
Incorrect Answers
A:This predicts that the snippet prints '2\n0', but executing the displayed Python 3 code prints '0\n2'. Python statements execute in source order; earlier assignments and prints take effect before later ones.
B:This predicts that the snippet prints '0', but executing the displayed Python 3 code prints '0\n2'. Python statements execute in source order; earlier assignments and prints take effect before later ones.
D:This predicts that the snippet prints '2', but executing the displayed Python 3 code prints '0\n2'. Python statements execute in source order; earlier assignments and prints take effect before later ones.
Question 5
A learner is checking case-sensitive identifiers. What is the exact printed result or uncaught exception?Level=4
print(level)
- Raises KeyError
- Raises TypeError
- Raises NameError
- Raises IndexError
Explanation
Correct Answer
C:The snippet raises nameerror. Python identifiers distinguish lowercase and uppercase letters; names that differ in case are different bindings.
Incorrect Answers
A:This predicts that the snippet raises keyerror, but executing the displayed Python 3 code raises nameerror. Python identifiers distinguish lowercase and uppercase letters; names that differ in case are different bindings.
B:This predicts that the snippet raises typeerror, but executing the displayed Python 3 code raises nameerror. Python identifiers distinguish lowercase and uppercase letters; names that differ in case are different bindings.
D:This predicts that the snippet raises indexerror, but executing the displayed Python 3 code raises nameerror. Python identifiers distinguish lowercase and uppercase letters; names that differ in case are different bindings.
Question 6
A developer tests case-sensitive identifiers. The following code prints '8 3'. Which explanation best accounts for that observed behavior?value=8
Value=3
print(value, Value)
- Python identifiers distinguish lowercase and uppercase letters; names that differ in case are different bindings.
- A chain of exponentiation operators groups from the right unless parentheses explicitly change the grouping.
- Python statements execute in source order; earlier assignments and prints take effect before later ones.
- Escape sequences such as \n and \t represent control characters inside strings rather than literal backslash-letter pairs.
Explanation
Correct Answer
A:This is the operative language rule for the code. It directly explains why the example prints '8 3'; the displayed behavior was independently reproduced by a Python 3 execution check.
Incorrect Answers
B:The right-associative exponentiation topic does not explain why the code prints '8 3'. The relevant Python rule is: Python identifiers distinguish lowercase and uppercase letters; names that differ in case are different bindings.
C:The sequential interpreter execution topic does not explain why the code prints '8 3'. The relevant Python rule is: Python identifiers distinguish lowercase and uppercase letters; names that differ in case are different bindings.
D:The escaped newline and tab characters topic does not explain why the code prints '8 3'. The relevant Python rule is: Python identifiers distinguish lowercase and uppercase letters; names that differ in case are different bindings.
Question 7
A learner is checking case-sensitive identifiers. After this modification, what does Python 3 actually do?City="Oslo"
print(city)
- Raises TypeError
- Raises KeyError
- Raises IndexError
- Raises NameError
Explanation
Correct Answer
D:The snippet raises nameerror. Python identifiers distinguish lowercase and uppercase letters; names that differ in case are different bindings.
Incorrect Answers
A:This predicts that the snippet raises typeerror, but executing the displayed Python 3 code raises nameerror. Python identifiers distinguish lowercase and uppercase letters; names that differ in case are different bindings.
B:This predicts that the snippet raises keyerror, but executing the displayed Python 3 code raises nameerror. Python identifiers distinguish lowercase and uppercase letters; names that differ in case are different bindings.
C:This predicts that the snippet raises indexerror, but executing the displayed Python 3 code raises nameerror. Python identifiers distinguish lowercase and uppercase letters; names that differ in case are different bindings.
Question 8
A learner is checking case-sensitive identifiers. Which final result follows from this separate test?score=5
SCORE=2
print(score+SCORE)
- Prints '8'
- Prints '9'
- Prints '6'
- Prints '7'
Explanation
Correct Answer
D:The snippet prints '7'. Python identifiers distinguish lowercase and uppercase letters; names that differ in case are different bindings.
Incorrect Answers
A:This predicts that the snippet prints '8', but executing the displayed Python 3 code prints '7'. Python identifiers distinguish lowercase and uppercase letters; names that differ in case are different bindings.
B:This predicts that the snippet prints '9', but executing the displayed Python 3 code prints '7'. Python identifiers distinguish lowercase and uppercase letters; names that differ in case are different bindings.
C:This predicts that the snippet prints '6', but executing the displayed Python 3 code prints '7'. Python identifiers distinguish lowercase and uppercase letters; names that differ in case are different bindings.
Question 9
A learner is checking indentation-defined code blocks. What is the exact printed result or uncaught exception?if True:
print("inside")
print("outside")
- Prints 'outside\ninside'
- Prints 'inside'
- Prints 'outside'
- Prints 'inside\noutside'
Explanation
Correct Answer
D:The snippet prints 'inside\noutside'. Indentation determines which statements are inside a Python suite; dedented statements run afterward.
Incorrect Answers
A:This predicts that the snippet prints 'outside\ninside', but executing the displayed Python 3 code prints 'inside\noutside'. Indentation determines which statements are inside a Python suite; dedented statements run afterward.
B:This predicts that the snippet prints 'inside', but executing the displayed Python 3 code prints 'inside\noutside'. Indentation determines which statements are inside a Python suite; dedented statements run afterward.
C:This predicts that the snippet prints 'outside', but executing the displayed Python 3 code prints 'inside\noutside'. Indentation determines which statements are inside a Python suite; dedented statements run afterward.
Question 10
A developer tests indentation-defined code blocks. The following code prints 'visible'. Which explanation best accounts for that observed behavior?if False:
print("hidden")
print("visible")
- Multiplication and division bind before addition and subtraction unless parentheses override precedence.
- Indentation determines which statements are inside a Python suite; dedented statements run afterward.
- 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.
Explanation
Correct Answer
B:This is the operative language rule for the code. It directly explains why the example prints 'visible'; the displayed behavior was independently reproduced by a Python 3 execution check.
Incorrect Answers
A:The multiplication and addition precedence topic does not explain why the code prints 'visible'. The relevant Python rule is: Indentation determines which statements are inside a Python suite; dedented statements run afterward.
C:The sequential interpreter execution topic does not explain why the code prints 'visible'. The relevant Python rule is: Indentation determines which statements are inside a Python suite; dedented statements run afterward.
D:The comments and executable code topic does not explain why the code prints 'visible'. The relevant Python rule is: Indentation determines which statements are inside a Python suite; dedented statements run afterward.
PCEP - Certified Entry-Level Python Programmer (PCEP-30-02) Practice Tests