100% Latest & Updated Python Institute PCEP-30-02 Practice Test Questions, Exam Dumps & Verified Answers!
30 Days Free Updates, Instant Download!
Question 20
During a review of Boolean literals in numeric expressions, three independent Python 3 fragments are shown. Which TWO statements accurately describe their behavior? (Choose TWO.)Program A:
print(False*9+4)
Program B:
print(True==1)
Program C:
print(type(True).__name__)
- Program B prints '0\n2'.
- Program B prints 'true'.
- Program C prints '4\n9'.
- Program C prints 'bool'.
- Program A prints '7'.
Explanation
Correct Answers
B:Running Program Bprints 'true'. Boolean True and False behave as integer one and zero in Python arithmetic while remaining Boolean values.
D:Running Program C prints 'bool'. Boolean True and False behave as integer one and zero in Python arithmetic while remaining Boolean values.
Incorrect Answers
A:Program B does not produce '0\n2'; its verified result is:prints 'True'. Boolean True and False behave as integer one and zero in Python arithmetic while remaining Boolean values.
C:Program C does not produce '4\n9'; its verified result is: Prints 'bool'. Boolean True and False behave as integer one and zero in Python arithmetic while remaining Boolean values.
E:Program A does not produce '7'; its verified result is: Prints '4'. Boolean True and False behave as integer one and zero in Python arithmetic while remaining Boolean values.
Question 21
A learner is checking binary octal and hexadecimal integer literals. What is the exact printed result or uncaught exception?print(0b101+0xA)
- Prints '17'
- Prints '14'
- Prints '15'
- Prints '16'
Explanation
Correct Answer
C:The snippet prints '15'. Prefix 0b, 0o and 0x specifies the base of an integer literal, and mixed-base arithmetic uses numeric values.
Incorrect Answers
A:This predicts that the snippet prints '17', but executing the displayed Python 3 code prints '15'. Prefix 0b, 0o and 0x specifies the base of an integer literal, and mixed-base arithmetic uses numeric values.
B:This predicts that the snippet prints '14', but executing the displayed Python 3 code prints '15'. Prefix 0b, 0o and 0x specifies the base of an integer literal, and mixed-base arithmetic uses numeric values.
D:This predicts that the snippet prints '16', but executing the displayed Python 3 code prints '15'. Prefix 0b, 0o and 0x specifies the base of an integer literal, and mixed-base arithmetic uses numeric values.
Question 22
A developer tests binary octal and hexadecimal integer literals. The following code prints '12'. Which explanation best accounts for that observed behavior?print(0o17-0b11)
- Assignment rebinds a variable name to a new object; the new value determines later operations and its type.
- input returns a string; numeric calculations require explicit int or float conversion when text is provided.
- Indentation determines which statements are inside a Python suite; dedented statements run afterward.
- Prefix 0b, 0o and 0x specifies the base of an integer literal, and mixed-base arithmetic uses numeric values.
Explanation
Correct Answer
D:This is the operative language rule for the code. It directly explains why the example prints '12'; the displayed behavior was independently reproduced by a Python 3 execution check.
Incorrect Answers
A:The variable rebinding across types topic does not explain why the code prints '12'. The relevant Python rule is: Prefix 0b, 0o and 0x specifies the base of an integer literal, and mixed-base arithmetic uses numeric values.
B:The input strings and explicit conversion topic does not explain why the code prints '12'. The relevant Python rule is: Prefix 0b, 0o and 0x specifies the base of an integer literal, and mixed-base arithmetic uses numeric values.
C:The indentation-defined code blocks topic does not explain why the code prints '12'. The relevant Python rule is: Prefix 0b, 0o and 0x specifies the base of an integer literal, and mixed-base arithmetic uses numeric values.
Question 23
A learner is checking binary octal and hexadecimal integer literals. After this modification, what does Python 3 actually do?print(0x10//0b100)
- Prints '4'
- Prints '6'
- Prints '5'
- Prints '3'
Explanation
Correct Answer
A:The snippet prints '4'. Prefix 0b, 0o and 0x specifies the base of an integer literal, and mixed-base arithmetic uses numeric values.
Incorrect Answers
B:This predicts that the snippet prints '6', but executing the displayed Python 3 code prints '4'. Prefix 0b, 0o and 0x specifies the base of an integer literal, and mixed-base arithmetic uses numeric values.
C:This predicts that the snippet prints '5', but executing the displayed Python 3 code prints '4'. Prefix 0b, 0o and 0x specifies the base of an integer literal, and mixed-base arithmetic uses numeric values.
D:This predicts that the snippet prints '3', but executing the displayed Python 3 code prints '4'. Prefix 0b, 0o and 0x specifies the base of an integer literal, and mixed-base arithmetic uses numeric values.
Question 24
During a review of binary octal and hexadecimal integer literals, three independent Python 3 fragments are shown. Which TWO statements accurately describe their behavior? (Choose TWO.)Program A:
print(0o17-0b11)
Program B:
print(0x10//0b100)
Program C:
print(0o12==0xA)
- Program B prints '4'.
- Program C prints 'true'.
- Program A prints '14'.
- Program C prints 'bool'.
- Program B prints '0'.
Explanation
Correct Answers
A:Running Program B prints '4'. Prefix 0b, 0o and 0x specifies the base of an integer literal, and mixed-base arithmetic uses numeric values.
B:Running Program Cprints 'true'. Prefix 0b, 0o and 0x specifies the base of an integer literal, and mixed-base arithmetic uses numeric values.
Incorrect Answers
C:Program A does not produce '14'; its verified result is: Prints '12'. Prefix 0b, 0o and 0x specifies the base of an integer literal, and mixed-base arithmetic uses numeric values.
D:Program C does not produce 'bool'; its verified result is:prints 'True'. Prefix 0b, 0o and 0x specifies the base of an integer literal, and mixed-base arithmetic uses numeric values.
E:Program B does not produce '0'; its verified result is: Prints '4'. Prefix 0b, 0o and 0x specifies the base of an integer literal, and mixed-base arithmetic uses numeric values.
Question 25
A learner is checking scientific notation and float results. What is the exact printed result or uncaught exception?print(2e2+5)
- Prints '206.0'
- Prints '205.0'
- Prints '204.0'
- Prints '207.0'
Explanation
Correct Answer
B:The snippet prints '205.0'. An e-notation numeric literal produces a float whose exponent determines its decimal magnitude.
Incorrect Answers
A:This predicts that the snippet prints '206.0', but executing the displayed Python 3 code prints '205.0'. An e-notation numeric literal produces a float whose exponent determines its decimal magnitude.
C:This predicts that the snippet prints '204.0', but executing the displayed Python 3 code prints '205.0'. An e-notation numeric literal produces a float whose exponent determines its decimal magnitude.
D:This predicts that the snippet prints '207.0', but executing the displayed Python 3 code prints '205.0'. An e-notation numeric literal produces a float whose exponent determines its decimal magnitude.
Question 26
A developer tests scientific notation and float results. The following code prints '7.0'. Which explanation best accounts for that observed behavior?print(3.5e1/5)
- An e-notation numeric literal produces a float whose exponent determines its decimal magnitude.
- The / operator returns a float whereas // floors the quotient toward negative infinity.
- Exponentiation binds before a leading unary minus, so -a**b negates the power rather than the base.
- Indentation determines which statements are inside a Python suite; dedented statements run afterward.
Explanation
Correct Answer
A:This is the operative language rule for the code. It directly explains why the example prints '7.0'; the displayed behavior was independently reproduced by a Python 3 execution check.
Incorrect Answers
B:The true division versus floor division topic does not explain why the code prints '7.0'. The relevant Python rule is: An e-notation numeric literal produces a float whose exponent determines its decimal magnitude.
C:The unary minus relative to exponentiation topic does not explain why the code prints '7.0'. The relevant Python rule is: An e-notation numeric literal produces a float whose exponent determines its decimal magnitude.
D:The indentation-defined code blocks topic does not explain why the code prints '7.0'. The relevant Python rule is: An e-notation numeric literal produces a float whose exponent determines its decimal magnitude.
Question 27
A learner is checking scientific notation and float results. After this modification, what does Python 3 actually do?print(type(7e0).__name__)
- Prints 'taolf'
- Prints 'float'
- Prints 'floa'
- Prints 'float?'
Explanation
Correct Answer
B:The snippet prints 'float'. An e-notation numeric literal produces a float whose exponent determines its decimal magnitude.
Incorrect Answers
A:This predicts that the snippet prints 'taolf', but executing the displayed Python 3 code prints 'float'. An e-notation numeric literal produces a float whose exponent determines its decimal magnitude.
C:This predicts that the snippet prints 'floa', but executing the displayed Python 3 code prints 'float'. An e-notation numeric literal produces a float whose exponent determines its decimal magnitude.
D:This predicts that the snippet prints 'float?', but executing the displayed Python 3 code prints 'float'. An e-notation numeric literal produces a float whose exponent determines its decimal magnitude.
Question 28
During a review of scientific notation and float results, three independent Python 3 fragments are shown. Which TWO statements accurately describe their behavior? (Choose TWO.)Program A:
print(3.5e1/5)
Program B:
print(type(7e0).__name__)
Program C:
print(1.2e-1*10)
- Program C prints '1.2'.
- Program B prints 'float'.
- Program A prints '512'.
- Program C prints '8 3'.
- Program B prints '1|2|3'.
Explanation
Correct Answers
A:Running Program C prints '1.2'. An e-notation numeric literal produces a float whose exponent determines its decimal magnitude.
B:Running Program B prints 'float'. An e-notation numeric literal produces a float whose exponent determines its decimal magnitude.
Incorrect Answers
C:Program A does not produce '512'; its verified result is: Prints '7.0'. An e-notation numeric literal produces a float whose exponent determines its decimal magnitude.
D:Program C does not produce '8 3'; its verified result is: Prints '1.2'. An e-notation numeric literal produces a float whose exponent determines its decimal magnitude.
E:Program B does not produce '1|2|3'; its verified result is: Prints 'float'. An e-notation numeric literal produces a float whose exponent determines its decimal magnitude.
Question 29
A learner is checking escaped newline and tab characters. What is the exact printed result or uncaught exception?print("a\nb")
- Prints 'b'
- Prints 'a'
- Prints 'b\na'
- Prints 'a\nb'
Explanation
Correct Answer
D:The snippet prints 'a\nb'. 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 'b', but executing the displayed Python 3 code prints 'a\nb'. 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 'a', but executing the displayed Python 3 code prints 'a\nb'. 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 'b\na', but executing the displayed Python 3 code prints 'a\nb'. Escape sequences such as \n and \t represent control characters inside strings rather than literal backslash-letter pairs.
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.
PCEP - Certified Entry-Level Python Programmer (PCEP-30-02) Practice Tests