Free PCEP™ – Certified Entry-Level Python Programmer Practice Questions
100 free questions · Answer explanations · No signup required
View examination details, outline and sourcesLoading selected examination banks…
Sample Practice Questions
Try these 10 sample questions from the PCEP™ – Certified Entry-Level Python Programmer practice bank. Each includes the answer and explanation. Continue with the interactive practice above to review the full question set.
1What does describing Python as an interpreted language imply for running a source file?
- A. It must first be translated into a separate native executable.
- B. It can run without explicitly creating a separate executable.
- C. It must first be entered at an interactive prompt.
- D. It can run only after every expression is replaced by bytecode manually.
Answer: B
Explanation: "This means that source files can be run directly without explicitly creating an executable which is then run." Running a script does not require the user to build a separate executable. This does not require interactive entry or manual bytecode translation.
2What does this code print? ```python score = 85 if score >= 60: print("pass") elif score >= 80: print("merit") else: print("retry") ```
- A. merit
- B. pass
- C. pass then merit
- D. retry
Answer: B
Explanation: "It selects exactly one of the suites by evaluating the expressions one by one until one is found to be true" The first condition is true, so its suite runs and the later elif is skipped even though its condition would also be true.
Reference: The Python Language Reference — Compound statements — 8.1. The if statement
3What is the value of `numbers[1:4]` when `numbers = [10, 20, 30, 40, 50]`?
- A. [10, 20, 30, 40]
- B. [20, 30, 40, 50]
- C. [20, 30, 40]
- D. [20, 30]
4What is printed by this code? ```python def announce(): print("inside") print("outside") ```
- A. inside then outside
- B. outside then inside
- C. Only outside
- D. Only inside
Answer: C
Explanation: "The function definition does not execute the function body; this gets executed only when the function is called." The definition creates the function but does not call it. Only the print outside the function executes.
Reference: The Python Language Reference — Compound statements — 8.7. Function definitions, execution of definition
5In CPython, what does the bytecode compiler produce from Python source code?
- A. A table of the final runtime variable values
- B. A token stream passed directly to the parser
- C. Native machine instructions executed by the processor
- D. An internal representation executed by the virtual machine
Answer: D
Explanation: "Python source code is compiled into bytecode, the internal representation of a Python program in the CPython interpreter." The bytecode compiler produces an intermediate representation for execution by the virtual machine. A token stream is the lexical analyzer's output, final variable values come from execution, and native processor instructions are a different representation.
6What is the final value of status? ```python status = "waiting" if 4 > 9: status = "ready" ```
- A. "ready"
- B. None
- C. "waiting"
- D. False
Answer: C
Explanation: "If all expressions are false, the suite of the else clause, if present, is executed." The condition is false and no else suite exists, so the assignment inside the if does not run. The previous binding is retained.
Reference: The Python Language Reference — Compound statements — 8.1. The if statement
7What does a contain after this code? ```python a = [1, 2] a.append([3, 4]) ```
- A. A three-item list: [1, 2, [3, 4]]
- B. A four-item list: [1, 2, 3, 4]
- C. A two-item nested list: [[1, 2], [3, 4]]
- D. A replacement list: [3, 4]
8What result does the caller receive when choose reaches its first return statement? ```python def choose(): return 4 return 9 ```
- A. 4
- B. 9
- C. (4, 9)
- D. None
Answer: A
Explanation: "return leaves the current function call with the expression list (or None) as return value." The first return immediately leaves the call with 4. The later return is not executed, and the results are not collected into a tuple.
Reference: The Python Language Reference — Simple statements — 7.6. The return statement
9Which task belongs to lexical analysis when Python source code is processed?
- A. Breaking source characters into tokens
- B. Calculating the values returned by functions
- C. Choosing which conditional branch executes
- D. Allocating the objects created by a running program
Answer: A
Explanation: "This chapter describes how the lexical analyzer breaks a file into tokens." Lexical analysis identifies tokens before parsing and execution. Evaluating functions, choosing branches, and creating runtime objects are different tasks.
Reference: The Python Language Reference — Lexical analysis — 2. Lexical analysis, opening paragraphs
10What is the final value of n after these separate if statements? ```python n = 1 if n == 1: n = 2 if n == 2: n = 5 ```
- A. 1
- B. 2
- C. 3
- D. 5
Answer: D
Explanation: "It selects exactly one of the suites by evaluating the expressions one by one until one is found to be true (see section Boolean operations for the definition of true and false); then that suite is executed (and no other part of the if statement is executed or evaluated)." This rule applies separately to each if statement. The first compares n with 1 and changes it to 2. The second then compares the updated n with 2 and changes it to 5; it is not an elif in the first statement.
Reference: The Python Language Reference — Compound statements — 8.1. The if statement
Topics in this practice bank
These topics describe the available practice for PCEP™ – Certified Entry-Level Python Programmer. Review the examination outline and its sources for scope and allocation details.
Computer Programming and Python Fundamentals
- Understand fundamental terms and definitions
- Understand Python’s logic and structure
- Introduce literals and variables into code and use different numeral systems
- Choose operators and data types adequate to the problem
- Perform Input/Output console operations
Control Flow – Conditional Blocks and Loops
- Make decisions and branch the flow with the if instruction
- Perform different types of iterations
Data Collections – Tuples, Dictionaries, Lists, and Strings
- Collect and process data using lists
- Collect and process data using tuples
- Collect and process data using dictionaries
- Operate with strings
Functions and Exceptions
- Decompose the code using functions
- Organize interaction between the function and its environment
- Python Built-In Exceptions Hierarchy
- Basics of Python Exception Handling
How to use these free practice questions
Choose an answer, check the explanation, and review your progress by chapter. Practice questions and explanations are free to access without signing up.
These are independent study questions, not actual examination items. For examination requirements and official information, view PCEP™ – Certified Entry-Level Python Programmer details.