OpenExamsFREE PRACTICE — ANY EXAM

Free PCEP™ – Certified Entry-Level Python Programmer Practice Questions

100 free questions · Answer explanations · No signup required

View examination details, outline and sources

Loading 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.

  1. 1What does describing Python as an interpreted language imply for running a source file?

    1. A. It must first be translated into a separate native executable.
    2. B. It can run without explicitly creating a separate executable.
    3. C. It must first be entered at an interactive prompt.
    4. 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.

    Reference: Python 3.13 Glossary — Glossary: interpreted

  2. 2What does this code print? ```python score = 85 if score >= 60: print("pass") elif score >= 80: print("merit") else: print("retry") ```

    1. A. merit
    2. B. pass
    3. C. pass then merit
    4. 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

  3. 3What is the value of `numbers[1:4]` when `numbers = [10, 20, 30, 40, 50]`?

    1. A. [10, 20, 30, 40]
    2. B. [20, 30, 40, 50]
    3. C. [20, 30, 40]
    4. D. [20, 30]

    Answer: C

    Explanation: "The slice of s from i to j is defined as the sequence of items with index k such that i <= k < j." Indices 1, 2, and 3 are included, while index 4 is excluded.

    Reference: Python 3.13 — Built-in Types — Common Sequence Operations, slice bounds

  4. 4What is printed by this code? ```python def announce(): print("inside") print("outside") ```

    1. A. inside then outside
    2. B. outside then inside
    3. C. Only outside
    4. 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

  5. 5In CPython, what does the bytecode compiler produce from Python source code?

    1. A. A table of the final runtime variable values
    2. B. A token stream passed directly to the parser
    3. C. Native machine instructions executed by the processor
    4. 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.

    Reference: Python 3.13 Glossary — Glossary: bytecode

  6. 6What is the final value of status? ```python status = "waiting" if 4 > 9: status = "ready" ```

    1. A. "ready"
    2. B. None
    3. C. "waiting"
    4. 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

  7. 7What does a contain after this code? ```python a = [1, 2] a.append([3, 4]) ```

    1. A. A three-item list: [1, 2, [3, 4]]
    2. B. A four-item list: [1, 2, 3, 4]
    3. C. A two-item nested list: [[1, 2], [3, 4]]
    4. D. A replacement list: [3, 4]

    Answer: A

    Explanation: "Add an item to the end of the list." append adds its argument as one item, preserving the list argument as a nested list. extend would add its individual elements.

    Reference: The Python Tutorial — Data Structures — 5.1. More on Lists — list.append

  8. 8What result does the caller receive when choose reaches its first return statement? ```python def choose(): return 4 return 9 ```

    1. A. 4
    2. B. 9
    3. C. (4, 9)
    4. 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

  9. 9Which task belongs to lexical analysis when Python source code is processed?

    1. A. Breaking source characters into tokens
    2. B. Calculating the values returned by functions
    3. C. Choosing which conditional branch executes
    4. 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

  10. 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 ```

    1. A. 1
    2. B. 2
    3. C. 3
    4. 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.