PCEP – Certified Entry-Level Python Programmer (PCEP-30-02) Exam-style mock test
PCEP (PCEP-30-02) Practice Exams — 6 Python Mock Tests|Practice test
Full explanations
Exam format
Pass line 70%
33 USD One-time · lifetime access
Enroll →
Sample questions
Example1 · Computer Programming and Python Fundamentals
A junior developer on a lending team asks how CPython actually runs the deposit script they just saved. Which description of Python's standard execution model is accurate?
・The source is turned into a standalone machine binary before any line runs.
Incorrect. A full compiler to native machine code ahead of time describes compiled languages, not the standard Python flow.
・The source is first checked only for spelling and then never truly executed.
Incorrect. Syntax is only part of the story, and the program genuinely runs after passing checks.
・The source must be rewritten in C before the computer can run it.
Incorrect. No manual translation into C is required for Python to run a script.
✓The source is read and executed by an interpreter as the program runs.
Correct. Python's default model reads and executes the source through an interpreter at run time rather than producing a prior native binary.
Explanation
Python uses an interpreter that processes the source as the program runs, unlike languages compiled ahead of time to native binaries.
Example2 · Control Flow – Conditional Blocks and Loops
A loan grader classifies a credit score. What does this code print?
score = 690
if score >= 750:
print("gold")
elif score >= 650:
print("silver")
else:
print("basic")
・gold
Incorrect. The gold branch needs a score of 750 or more, which 690 does not meet.
✓silver
Correct. 690 is below 750 but at least 650, so the elif branch runs and prints silver.
・basic
Incorrect. The else branch runs only when no earlier condition is true, but the elif already matched.
・silver then basic
Incorrect. Only one branch of an if chain executes, so two lines are not printed.
Explanation
An if-elif-else chain stops at the first true test; 690 satisfies the elif, so only silver prints.
Example3 · Data Collections – Tuples, Dictionaries, Lists, and Strings
A portfolio holds monthly returns in a list. What does this code print?
gains = [10, 20, 30, 40, 50]
print(gains[1:4])
✓[20, 30, 40]
Correct. The slice starts at index 1 and stops before index 4, yielding 20, 30, and 40.
・[10, 20, 30, 40]
Incorrect. This starts at index 0 instead of index 1.
・[20, 30, 40, 50]
Incorrect. This includes index 4, but the stop bound is exclusive.
・[10, 20, 30]
Incorrect. This drops the element at index 3 that the slice includes.
Explanation
A slice [1:4] returns items at indices 1, 2, and 3, since the start is inclusive and the stop is exclusive.
Example4 · Functions and Exceptions
A function returns a label only in one case. What is printed?
def record(temp):
if temp > 37.5:
return "fever"
print(record(37.0))
・fever
Incorrect. The fever label is returned only when the temperature is above the threshold.
・37.0
Incorrect. The function returns a label or None, never the raw argument value.
・an error because the function sometimes returns nothing
Incorrect. Reaching the end of a function without a return statement is legal and yields None.
✓None
Correct. The argument does not exceed the threshold, so the function falls off the end and returns None.
Explanation
A function that reaches its end without executing a return statement returns None, so the below-threshold call prints None.
Example5 · Computer Programming and Python Fundamentals
A clinic stores three dose counts written in different numeral systems. What does this program print?
doses = 0b1010 + 0o17 + 0x1F
print(doses)
・52
Incorrect. That total would require different literal values; these three convert to 10, 15, and 31.
✓56
Correct. 0b1010 is 10, 0o17 is 15, and 0x1F is 31, so the sum is 56.
・0b111000
Incorrect. Integer literals in different bases evaluate to plain integers, and the sum is printed in decimal.
・an error about mixing numeral systems
Incorrect. Mixing numeral-system literals in arithmetic is valid because each evaluates to an integer first.
Explanation
Binary, octal, and hexadecimal literals all evaluate to ordinary integers (10, 15, 31), so their sum prints as the decimal value 56.
Example6 · Computer Programming and Python Fundamentals
A nurse compares a computed temperature to an expected value. What is printed?
temp = 36.1 + 0.2
print(temp == 36.3)
・True
Incorrect. Binary floating-point cannot represent these decimals exactly, so the equality does not hold.
✓False
Correct. 36.1 + 0.2 produces 36.300000000000004 because of binary floating-point rounding, so the comparison yields a negative result.
・36.3
Incorrect. The print call reports the result of the comparison, not the numeric value itself.
・the program raises an error
Incorrect. Adding and comparing floats is valid, so no error is raised here.
Explanation
Floating-point values are stored in binary and cannot represent most decimal fractions exactly, so 36.1 + 0.2 is slightly off from 36.3 and the comparison is not equal.
Example7 · Computer Programming and Python Fundamentals
An online store writes a pricing script and wonders how CPython turns its text into actions. Which statement best describes compilation versus interpretation here?
・A compiler first translates the entire source into a standalone machine binary that the processor then runs directly without Python.
Incorrect. CPython does not produce a standalone native binary; it executes the code through the interpreter instead.
・The source is sent to a remote service that returns finished results instead of ever running locally on this machine.
Incorrect. The standard model runs the code locally through the interpreter, not by delegating to a remote service.
・The file is only spell-checked for typos and is never actually carried out by any program at all.
Incorrect. Checking for typos is only part of parsing; the interpreter then genuinely executes the instructions.
✓An interpreter reads the source and carries out its instructions while the program runs.
Correct. CPython interprets the source, executing instructions as the program runs rather than building a native binary.
Explanation
In the standard CPython model the interpreter reads the source and executes its instructions while the program runs, so no separate machine binary is created first.
Example8 · Computer Programming and Python Fundamentals
A warehouse tool records stock counts using two different numeral systems. What does this program print?
stock_hex = 0x2C
backroom = 0o20
print(stock_hex + backroom)
✓60
Correct. 0x2C is 44 and 0o20 is 16, so their sum prints as the decimal value 60.
・0x2C0o20
Incorrect. Literals in different bases are evaluated to integers, so the result is a number, not a joined text.
・76
Incorrect. That total would require other literal values; 0x2C is 44 and 0o20 is 16.
・An error about adding values from different numeral systems
Incorrect. Hexadecimal and octal literals become ordinary integers, so they add together without any error.
Explanation
Hexadecimal 0x2C equals 44 and octal 0o20 equals 16; both literals become plain integers, so the sum prints as 60 in decimal.
Example9 · Computer Programming and Python Fundamentals
A checkout routine evaluates a discount expression that mixes several operators. What value does it print?
price = 10 - 2 ** 3 // 2
print(price)
・1
Incorrect. That would treat subtraction as happening before the power and the floor division.
・64
Incorrect. That ignores the floor division and the subtraction applied after the exponent.
・512
Incorrect. That treats the whole expression as one chained power, which is not how binding works.
✓6
Correct. 2 ** 3 is 8, then 8 // 2 is 4, and 10 - 4 leaves 6.
Explanation
Exponentiation binds first (2 ** 3 is 8), then floor division (8 // 2 is 4), and subtraction runs last, so 10 - 4 prints 6.
Example10 · Computer Programming and Python Fundamentals
A field engineer asks how the standard CPython tool processes a sensor logging script before it runs. Which statement about Python's usual execution model is accurate?
・Source is first translated into native machine code and saved as a standalone executable before any line runs
Incorrect. A standalone native executable is produced by ahead-of-time compiled languages, not by the usual CPython workflow.
✓Source is read and run by an interpreter, which handles each statement in turn
Correct. CPython relies on an interpreter that reads the program and carries out its statements in order at run time.
・Source must first be converted to another language such as C and then compiled
Incorrect. Translating to C and compiling it describes a different toolchain and is not how a plain script is run.
・Source runs only after a separate linker joins it with the operating system kernel
Incorrect. A kernel linking step is not part of launching an ordinary Python script.
Explanation
Python code is normally carried out by an interpreter that processes statements at run time, rather than compiled ahead of time into a native executable.
Example11 · Computer Programming and Python Fundamentals
A logger stores two sensor counts written in different numeral systems. What does this code print?
pulses = 0b1101
humidity = 0x0C
print(pulses + humidity)
・13
Incorrect. 13 is only the binary part; the hexadecimal value still has to be added in.
・0b11010x0C
Incorrect. Both literals become integers, so the result is a number rather than joined text.
・A type error about mixed bases
Incorrect. Literals in different bases are all integers, so adding them raises nothing.
✓25
Correct. Binary 0b1101 is 13 and hexadecimal 0x0C is 12, so the sum is 25.
Explanation
Binary 0b1101 equals 13 and hexadecimal 0x0C equals 12; both are ordinary integers, so the sum is 25.
Example12 · Computer Programming and Python Fundamentals
A civic-records team saves a residency script and wants to know when syntax and lexis are actually checked by the standard CPython tool. Which statement describes that model most accurately?
・The source is translated once into a standalone machine-code file that then runs with no interpreter present at all.
Incorrect. Standard CPython does not produce a standalone native executable; an interpreter is still needed to run the bytecode.
✓CPython reads the source, compiles it to bytecode, and the interpreter then executes that bytecode.
Correct. CPython first compiles the source into bytecode and then its virtual machine interprets that bytecode as the program runs.
・Each line is sent to the processor as raw text, so the terms lexis and syntax have no role at run time.
Incorrect. Lexis and syntax are analysed during compilation before execution, so they very much have a role.
・The program is checked only after it finishes, so an error on the first instruction is reported last.
Incorrect. Compilation happens before execution, so a syntax error is reported before any statement runs, not last.
Explanation
In standard CPython the source text is lexed and parsed, compiled to intermediate bytecode, and the interpreter then executes that bytecode; it is not turned into a native standalone binary.
Example13 · Computer Programming and Python Fundamentals
A registry assigns district identifiers written in two different numeral systems and multiplies them. What does this code print?
district = 0b1001
sector = 0x0A
print(district * sector)
✓90
Correct. The binary literal 0b1001 is 9 and the hexadecimal literal 0x0A is 10, so 9 multiplied by 10 gives 90.
・19
Incorrect. Adding the two values would give 19, but the code multiplies rather than adds them.
・910
Incorrect. Numeral prefixes are converted to integers before the operation, so the digits are not simply joined into 910.
・0b10110100
Incorrect. Multiplication yields a decimal integer, and print shows it in base ten rather than as a binary literal.
Explanation
Integer literals in binary and hexadecimal are converted to their decimal values first, so 0b1001 is 9 and 0x0A is 10, and 9 * 10 prints as 90.
Example14 · Computer Programming and Python Fundamentals
A gameplay engineer argues about whether Python needs a separate build step before a scoring script can run. Which statement best describes how the standard CPython tool treats the source each time it is launched?
✓It reads and carries out the source on each run, translating as it goes.
Correct. CPython interprets the program, translating and executing the source during each run rather than demanding a separate build first.
・It produces a machine-code executable once, after which the source file is never again consulted at all.
Incorrect. No persistent native executable is emitted; the interpreter works from the source on each launch.
・It requires the programmer to translate the whole file into assembly by hand before ever launching it.
Incorrect. The interpreter handles translation itself, so no manual assembly conversion is needed.
・It discards every comment and keyword so the bare hardware can then read the raw text directly.
Incorrect. The CPU never reads Python source directly; the interpreter mediates every instruction.
Explanation
Python is an interpreted language: the interpreter reads the source and executes it each run, so there is no obligatory standalone compilation step producing a native binary.
Example15 · Computer Programming and Python Fundamentals
A scoreboard stores one count in octal and one in binary, then subtracts them. What does this code print?
lives = 0o17
bonus = 0b101
print(lives - bonus)
✓10
Correct. The octal literal 0o17 is 15 and the binary literal 0b101 is 5, so 15 minus 5 prints 10 in decimal.
・12
Incorrect. This would require the octal literal to equal 17 in decimal, but 0o17 is 15.
・22
Incorrect. Adding the two values would give 20, and even that does not match; the operator is subtraction.
・0o12
Incorrect. Arithmetic results print as plain decimal integers, not with an octal prefix.
Explanation
0o17 equals 15 and 0b101 equals 5; integers from any numeral system share one internal representation, so 15 - 5 evaluates to the decimal integer 10.
▶ Try 10 free questions (graded)