100% Latest & Updated Python Institute PCEP-30-02 Practice Test Questions, Exam Dumps & Verified Answers!
30 Days Free Updates, Instant Download!
Question 30
A developer tests escaped newline and tab characters. The following code prints '3'. Which explanation best accounts for that observed behavior?print(len("x\ty"))
- Escape sequences such as \n and \t represent control characters inside strings rather than literal backslash-letter pairs.
- Assignment rebinds a variable name to a new object; the new value determines later operations and its type.
- Boolean True and False behave as integer one and zero in Python arithmetic while remaining Boolean values.
- An e-notation numeric literal produces a float whose exponent determines its decimal magnitude.
Explanation
Correct Answer
A:This is the operative language rule for the code. It directly explains why the example prints '3'; the displayed behavior was independently reproduced by a Python 3 execution check.
Incorrect Answers
B:The variable rebinding across types topic does not explain why the code prints '3'. The relevant Python rule is: Escape sequences such as \n and \t represent control characters inside strings rather than literal backslash-letter pairs.
C:The Boolean literals in numeric expressions topic does not explain why the code prints '3'. The relevant Python rule is: Escape sequences such as \n and \t represent control characters inside strings rather than literal backslash-letter pairs.
D:The scientific notation and float results topic does not explain why the code prints '3'. The relevant Python rule is: Escape sequences such as \n and \t represent control characters inside strings rather than literal backslash-letter pairs.
Question 31
A learner is checking escaped newline and tab characters. After this modification, what does Python 3 actually do?print("line\nend".splitlines())
- Prints "['end', 'line']"
- Prints "['end']"
- Prints "['line']"
- Prints "['line', 'end']"
Explanation
Correct Answer
D:The snippet prints "['line', 'end']". Escape sequences such as \n and \t represent control characters inside strings rather than literal backslash-letter pairs.
Incorrect Answers
A:This predicts that the snippet prints "['end', 'line']", but executing the displayed Python 3 code prints "['line', 'end']". Escape sequences such as \n and \t represent control characters inside strings rather than literal backslash-letter pairs.
B:This predicts that the snippet prints "['end']", but executing the displayed Python 3 code prints "['line', 'end']". Escape sequences such as \n and \t represent control characters inside strings rather than literal backslash-letter pairs.
C:This predicts that the snippet prints "['line']", but executing the displayed Python 3 code prints "['line', 'end']". Escape sequences such as \n and \t represent control characters inside strings rather than literal backslash-letter pairs.
Question 32
During a review of escaped newline and tab characters, three independent Python 3 fragments are shown. Which TWO statements accurately describe their behavior? (Choose TWO.)Program A:
print(len("x\ty"))
Program B:
print("line\nend".splitlines())
Program C:
print("\t"==" ")
- Program C prints '205.0'.
- Program A prints '0'.
- Program C prints 'false'.
- Program B prints "['line', 'end']".
- Program B raises zerodivisionerror.
Explanation
Correct Answers
C:Running Program C prints 'false'. Escape sequences such as \n and \t represent control characters inside strings rather than literal backslash-letter pairs.
D:Running Program B prints "['line', 'end']". Escape sequences such as \n and \t represent control characters inside strings rather than literal backslash-letter pairs.
Incorrect Answers
A:Program C does not produce '205.0'; its verified result is: Prints 'False'. Escape sequences such as \n and \t represent control characters inside strings rather than literal backslash-letter pairs.
B:Program A does not produce '0'; its verified result is: Prints '3'. Escape sequences such as \n and \t represent control characters inside strings rather than literal backslash-letter pairs.
E:Program B does not raises zerodivisionerror; its verified result is: Prints "['line', 'end']". Escape sequences such as \n and \t represent control characters inside strings rather than literal backslash-letter pairs.
Question 33
A learner is checking variable rebinding across types. What is the exact printed result or uncaught exception?x=5
x="five"
print(type(x).__name__)
- Prints 'st'
- Prints 'str'
- Prints 'str?'
- Prints 'rts'
Explanation
Correct Answer
B:The snippet prints 'str'. Assignment rebinds a variable name to a new object; the new value determines later operations and its type.
Incorrect Answers
A:This predicts that the snippet prints 'st', but executing the displayed Python 3 code prints 'str'. Assignment rebinds a variable name to a new object; the new value determines later operations and its type.
C:This predicts that the snippet prints 'str?', but executing the displayed Python 3 code prints 'str'. Assignment rebinds a variable name to a new object; the new value determines later operations and its type.
D:This predicts that the snippet prints 'rts', but executing the displayed Python 3 code prints 'str'. Assignment rebinds a variable name to a new object; the new value determines later operations and its type.
Question 34
A developer tests variable rebinding across types. The following code prints '7'. Which explanation best accounts for that observed behavior?rate=4
rate=rate+3
print(rate)
- Escape sequences such as \n and \t represent control characters inside strings rather than literal backslash-letter pairs.
- Assignment rebinds a variable name to a new object; the new value determines later operations and its type.
- Bitwise operations work on integer bits: & keeps common set bits, | combines them, and shifts move bit positions.
- Prefix 0b, 0o and 0x specifies the base of an integer literal, and mixed-base arithmetic uses numeric values.
Explanation
Correct Answer
B:This is the operative language rule for the code. It directly explains why the example prints '7'; 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 '7'. The relevant Python rule is: Assignment rebinds a variable name to a new object; the new value determines later operations and its type.
C:The bitwise masking and shifts topic does not explain why the code prints '7'. The relevant Python rule is: Assignment rebinds a variable name to a new object; the new value determines later operations and its type.
D:The binary octal and hexadecimal integer literals topic does not explain why the code prints '7'. The relevant Python rule is: Assignment rebinds a variable name to a new object; the new value determines later operations and its type.
Question 35
A learner is checking variable rebinding across types. After this modification, what does Python 3 actually do?code="2"
code=int(code)
print(code+4)
- Prints '5'
- Prints '8'
- Prints '7'
- Prints '6'
Explanation
Correct Answer
D:The snippet prints '6'. Assignment rebinds a variable name to a new object; the new value determines later operations and its type.
Incorrect Answers
A:This predicts that the snippet prints '5', but executing the displayed Python 3 code prints '6'. Assignment rebinds a variable name to a new object; the new value determines later operations and its type.
B:This predicts that the snippet prints '8', but executing the displayed Python 3 code prints '6'. Assignment rebinds a variable name to a new object; the new value determines later operations and its type.
C:This predicts that the snippet prints '7', but executing the displayed Python 3 code prints '6'. Assignment rebinds a variable name to a new object; the new value determines later operations and its type.
Question 36
During a review of variable rebinding across types, three independent Python 3 fragments are shown. Which TWO statements accurately describe their behavior? (Choose TWO.)Program A:
rate=4
rate=rate+3
print(rate)
Program B:
code="2"
code=int(code)
print(code+4)
Program C:
status=False
status=7
print(status)
- Program C prints '7'.
- Program C prints '9'.
- Program A prints '3'.
- Program B prints '6'.
- Program B prints '5'.
Explanation
Correct Answers
A:Running Program C prints '7'. Assignment rebinds a variable name to a new object; the new value determines later operations and its type.
D:Running Program B prints '6'. Assignment rebinds a variable name to a new object; the new value determines later operations and its type.
Incorrect Answers
B:Program C does not produce '9'; its verified result is: Prints '7'. Assignment rebinds a variable name to a new object; the new value determines later operations and its type.
C:Program A does not produce '3'; its verified result is: Prints '7'. Assignment rebinds a variable name to a new object; the new value determines later operations and its type.
E:Program B does not produce '5'; its verified result is: Prints '6'. Assignment rebinds a variable name to a new object; the new value determines later operations and its type.
Question 37
A learner is checking right-associative exponentiation. What is the exact printed result or uncaught exception?print(2**3**2)
- Prints '512'
- Prints '511'
- Prints '514'
- Prints '513'
Explanation
Correct Answer
A:The snippet prints '512'. A chain of exponentiation operators groups from the right unless parentheses explicitly change the grouping.
Incorrect Answers
B:This predicts that the snippet prints '511', but executing the displayed Python 3 code prints '512'. A chain of exponentiation operators groups from the right unless parentheses explicitly change the grouping.
C:This predicts that the snippet prints '514', but executing the displayed Python 3 code prints '512'. A chain of exponentiation operators groups from the right unless parentheses explicitly change the grouping.
D:This predicts that the snippet prints '513', but executing the displayed Python 3 code prints '512'. A chain of exponentiation operators groups from the right unless parentheses explicitly change the grouping.
Question 38
A developer tests right-associative exponentiation. The following code prints '64'. Which explanation best accounts for that observed behavior?print((2**3)**2)
- A chain of exponentiation operators groups from the right unless parentheses explicitly change the grouping.
- Python identifiers distinguish lowercase and uppercase letters; names that differ in case are different bindings.
- Assignment rebinds a variable name to a new object; the new value determines later operations and its type.
- Prefix 0b, 0o and 0x specifies the base of an integer literal, and mixed-base arithmetic uses numeric values.
Explanation
Correct Answer
A:This is the operative language rule for the code. It directly explains why the example prints '64'; the displayed behavior was independently reproduced by a Python 3 execution check.
Incorrect Answers
B:The case-sensitive identifiers topic does not explain why the code prints '64'. The relevant Python rule is: A chain of exponentiation operators groups from the right unless parentheses explicitly change the grouping.
C:The variable rebinding across types topic does not explain why the code prints '64'. The relevant Python rule is: A chain of exponentiation operators groups from the right unless parentheses explicitly change the grouping.
D:The binary octal and hexadecimal integer literals topic does not explain why the code prints '64'. The relevant Python rule is: A chain of exponentiation operators groups from the right unless parentheses explicitly change the grouping.
Question 39
A learner is checking right-associative exponentiation. After this modification, what does Python 3 actually do?print(3**2**2)
- Prints '81'
- Prints '83'
- Prints '80'
- Prints '82'
Explanation
Correct Answer
A:The snippet prints '81'. A chain of exponentiation operators groups from the right unless parentheses explicitly change the grouping.
Incorrect Answers
B:This predicts that the snippet prints '83', but executing the displayed Python 3 code prints '81'. A chain of exponentiation operators groups from the right unless parentheses explicitly change the grouping.
C:This predicts that the snippet prints '80', but executing the displayed Python 3 code prints '81'. A chain of exponentiation operators groups from the right unless parentheses explicitly change the grouping.
D:This predicts that the snippet prints '82', but executing the displayed Python 3 code prints '81'. A chain of exponentiation operators groups from the right unless parentheses explicitly change the grouping.
Question 40
During a review of right-associative exponentiation, three independent Python 3 fragments are shown. Which TWO statements accurately describe their behavior? (Choose TWO.)Program A:
print((2**3)**2)
Program B:
print(3**2**2)
Program C:
print(4**(1+1))
- Program B prints '81'.
- Program C prints '14'.
- Program C prints '16'.
- Program A prints '-3'.
- Program B prints '-2'.
Explanation
Correct Answers
A:Running Program B prints '81'. A chain of exponentiation operators groups from the right unless parentheses explicitly change the grouping.
C:Running Program C prints '16'. A chain of exponentiation operators groups from the right unless parentheses explicitly change the grouping.
Incorrect Answers
B:Program C does not produce '14'; its verified result is: Prints '16'. A chain of exponentiation operators groups from the right unless parentheses explicitly change the grouping.
D:Program A does not produce '-3'; its verified result is: Prints '64'. A chain of exponentiation operators groups from the right unless parentheses explicitly change the grouping.
E:Program B does not produce '-2'; its verified result is: Prints '81'. A chain of exponentiation operators groups from the right unless parentheses explicitly change the grouping.
PCEP - Certified Entry-Level Python Programmer (PCEP-30-02) Practice Tests