Skip to content
Zurück zu den Lernmaterialien

50 Free PCEP Practice Questions — Certified Entry-Level Python Programmer

29. Juli 2026~13 min read

Preparing for the PCEP certification? These 50 free practice questions cover all domains of the PCEP-30-02 exam.


Domain 1: Data Types & Variables (Questions 1–12)

Question 1

What is the output of print(type(42))?

a) <class 'int'>
b) <class 'float'>
c) <class 'str'>
d) <class 'bool'>

Show Answer

Answer: a) <class 'int'>

Explanation: 42 is an integer literal, so its type is int. Integers can be expressed in decimal, binary (0b), octal (0o), or hexadecimal (0x) notation.

Question 2

Which of the following is a valid variable name in Python?

a) 2nd_value
b) my-value
c) _myValue
d) class

Show Answer

Answer: c) _myValue

Explanation: Python variable names must start with a letter or underscore (_), followed by letters, digits, or underscores. They cannot start with a digit or be a Python keyword.

Question 3

What is the output of print(10 // 3)?

a) 3.333
b) 3
c) 3.0
d) 1

Show Answer

Answer: b) 3

Explanation: // is the floor division operator. It divides and returns the largest integer less than or equal to the result. 10 // 3 = 3.

Question 4

What is the output of print(10 % 3)?

a) 3
b) 3.333
c) 1
d) 0

Show Answer

Answer: c) 1

Explanation: % is the modulo operator, returning the remainder of the division. 10 divided by 3 is 3 remainder 1.

Question 5

What is the output of print(2 ** 3 ** 2)?

a) 64
b) 512
c) 36
d) 12

Show Answer

Answer: b) 512

Explanation: ** has right-to-left associativity, so 2 ** 3 ** 2 is 2 ** (3 ** 2) = 2 ** 9 = 512.

Question 6

What is the result of bool(0) in Python?

a) True
b) False
c) None
d) Error

Show Answer

Answer: b) False

Explanation: In Python, 0, None, empty sequences ("", [], (), {}, set()), and False evaluate to False. All other values evaluate to True.

Question 7

Which operator is used for string concatenation?

a) &
b) +
c) .
d) ,

Show Answer

Answer: b) +

Explanation: The + operator concatenates strings. "Hello" + " " + "World" returns "Hello World".

Question 8

What is the output of print("Hello" * 3)?

a) HelloHelloHello
b) Hello Hello Hello
c) HHeelllloo
d) Error

Show Answer

Answer: a) HelloHelloHello

Explanation: The * operator with a string and integer repeats the string. "Hello" * 3 gives "HelloHelloHello".

Question 9

What is the result of int("1010", 2)?

a) 1010
b) 10
c) 8
d) Error

Show Answer

Answer: b) 10

Explanation: int("1010", 2) converts the binary string "1010" to its decimal integer equivalent: 1×8 + 0×4 + 1×2 + 0×1 = 10.

Question 10

What is the output of print(0.1 + 0.2 == 0.3)?

a) True
b) False
c) Error
d) 0.3

Show Answer

Answer: b) False

Explanation: Due to floating-point precision, 0.1 + 0.2 produces 0.30000000000000004, which is not exactly equal to 0.3. This is a fundamental issue with binary floating-point arithmetic.

Question 11

What is the correct way to convert a string "42" to an integer?

a) to_int("42")
b) int("42")
c) "42".to_int()
d) integer("42")

Show Answer

Answer: b) int("42")

Explanation: int() is a built-in function that converts a string (or number) to an integer. If the string is not a valid integer, it raises ValueError.

Question 12

What is the output of print(round(3.14159, 2))?

a) 3.14
b) 3.14159
c) 3.15
d) 3.0

Show Answer

Answer: a) 3.14

Explanation: round(3.14159, 2) rounds the number to 2 decimal places, giving 3.14. The second argument specifies the number of decimal places.


Domain 2: Control Flow & Loops (Questions 13–27)

Question 13

What is the output of the following code?

x = 10
if x > 5:
    print("A")
elif x > 8:
    print("B")
else:
    print("C")

a) A
b) B
c) C
d) AB

Show Answer

Answer: a) A

Explanation: Since x=10 > 5 is True, the first if branch executes and prints "A". The elif and else branches are skipped. Python stops at the first true condition.

Question 14

How many times does "Hello" print in this loop?

for i in range(3):
    print("Hello")

a) 2
b) 3
c) 4
d) 1

Show Answer

Answer: b) 3

Explanation: range(3) generates numbers 0, 1, 2 — three values. The loop body executes three times, printing "Hello" three times.

Question 15

What is the output of print(list(range(2, 10, 3)))?

a) [2, 5, 8]
b) [2, 5, 8, 11]
c) [2, 3, 4, 5, 6, 7, 8, 9, 10]
d) [3, 6, 9]

Show Answer

Answer: a) [2, 5, 8]

Explanation: range(2, 10, 3) starts at 2, increments by 3 each step, and stops before 10. So it generates 2, 5, 8.

Question 16

What does the break statement do in a loop?

a) Pauses the loop
b) Exits the loop immediately
c) Skips the current iteration
d) Restarts the loop

Show Answer

Answer: b) Exits the loop immediately

Explanation: break immediately terminates the innermost loop it's in. The program continues with the next statement after the loop.

Question 17

What does the continue statement do in a loop?

a) Exits the loop
b) Skips the rest of the current iteration and continues with the next
c) Pauses the loop
d) Restarts the loop from the beginning

Show Answer

Answer: b) Skips the rest of the current iteration and continues with the next

Explanation: continue skips the remaining code in the current loop iteration and jumps to the next iteration.

Question 18

What is the output of the following code?

for i in range(3):
    for j in range(2):
        print(i, j)

a) 0 0 0 1 1 0 1 1 2 0 2 1
b) 0 0, 0 1, 1 0, 1 1, 2 0, 2 1
c) 0 0, 1 0, 2 0, 0 1, 1 1, 2 1
d) 0 0, 0 1, 1 0, 1 1, 2 0, 2 1

Show Answer

Answer: d) 0 0, 0 1, 1 0, 1 1, 2 0, 2 1

Explanation: Nested loops: for each i (0,1,2), the inner loop runs for j (0,1), producing 6 pairs: (0,0), (0,1), (1,0), (1,1), (2,0), (2,1).

Question 19

What is the output of this code?

x = 0
while x < 5:
    x += 2
print(x)

a) 4
b) 6
c) 5
d) 8

Show Answer

Answer: b) 6

Explanation: The loop increments x by 2 each iteration: x=0→2→4→6. When x=6, the condition x < 5 is False, so the loop ends and prints 6.

Question 20

Which loop is best when the number of iterations is known?

a) while loop
b) for loop
c) do-while loop
d) repeat loop

Show Answer

Answer: b) for loop

Explanation: for loops are ideal when iterating over a known sequence (range, list, string). while loops are better when the number of iterations depends on a condition.

Question 21

What is the output of this code?

for char in "abc":
    print(char, end=",")

a) a,b,c,
b) abc
c) a b c
d) Error

Show Answer

Answer: a) a,b,c,

Explanation: The loop iterates over each character in "abc", printing each followed by a comma without a newline (end=","). Output: a,b,c,

Question 22

What is the result of True and False?

a) True
b) False
c) None
d) 0

Show Answer

Answer: b) False

Explanation: In Python, and returns True only if both operands are True. True and False evaluates to False.

Question 23

What is the result of not (10 > 5)?

a) True
b) False
c) 5
d) None

Show Answer

Answer: b) False

Explanation: 10 > 5 is True, so not True is False.

Question 24

What does the in operator check for?

a) Whether a value is assigned to a variable
b) Whether a value exists in a sequence (list, string, tuple, etc.)
c) Whether a variable exists in memory
d) Whether a function is defined

Show Answer

Answer: b) Whether a value exists in a sequence (list, string, tuple, etc.)

Explanation: The in operator checks membership: "a" in "apple" returns True, 3 in [1, 2, 4] returns False.

Question 25

What is the output of this code?

if None:
    print("True")
else:
    print("False")

a) True
b) False
c) None
d) Error

Show Answer

Answer: b) False

Explanation: None evaluates to False in a boolean context. The else branch executes, printing "False".

Question 26

What is the output of print("a" in "banana")?

a) True
b) False
c) 1
d) 0

Show Answer

Answer: a) True

Explanation: "a" is a substring of "banana" (appears at positions 1, 3, 5). The in operator returns True.

Question 27

What is the output of this code?

for i in range(5):
    if i == 3:
        break
    print(i, end=" ")

a) 0 1 2
b) 0 1 2 3 4
c) 0 1 2 4
d) 0 1 2 3

Show Answer

Answer: a) 0 1 2

Explanation: The loop prints 0, 1, 2. When i=3, break exits the loop, so 3 is not printed.


Domain 3: Functions & Modules (Questions 28–37)

Question 28

Which keyword is used to define a function?

a) function
b) def
c) define
d) func

Show Answer

Answer: b) def

Explanation: Python functions are defined using def function_name(parameters):.

Question 29

What is the output of this code?

def add(a, b):
    return a + b

result = add(3, 4)
print(result)

a) 34
b) 7
c) (3, 4)
d) Error

Show Answer

Answer: b) 7

Explanation: The function add takes two parameters and returns their sum. add(3, 4) returns 7.

Question 30

What is the output of this code?

x = 10
def my_func():
    x = 5
    print(x)

my_func()
print(x)

a) 5 5
b) 10 10
c) 5 10
d) 10 5

Show Answer

Answer: c) 5 10

Explanation: Inside my_func, a local variable x is created with value 5. The global x remains 10. So inside the function x=5, outside x=10.

Question 31

What is a default parameter value?

a) A parameter that is always required
b) A parameter that has a fallback value if no argument is provided
c) A parameter that can only be positional
d) A parameter that can only be keyword

Show Answer

Answer: b) A parameter that has a fallback value if no argument is provided

Explanation: Default parameters are specified with =value in the function definition. If the caller doesn't provide that argument, the default value is used.

Question 32

What is the output of this code?

def greet(name="World"):
    return "Hello, " + name

print(greet("Python"))
print(greet())

a) Hello, World / Hello, World
b) Hello, Python / Hello, World
c) Hello, Python / Hello, Python
d) Error

Show Answer

Answer: b) Hello, Python / Hello, World

Explanation: First call passes "Python" explicitly. Second call uses the default "World".

Question 33

Which statement imports the math module?

a) import math
b) include math
c) using math
d) require math

Show Answer

Answer: a) import math

Explanation: import math makes all functions and constants from the math module available (e.g., math.sqrt(16)).

Question 34

What is a lambda function?

a) A named function defined with def
b) An anonymous one-line function
c) A built-in function
d) A recursive function

Show Answer

Answer: b) An anonymous one-line function

Explanation: Lambda functions are small anonymous functions defined with the lambda keyword: lambda x: x * 2. They can have any number of parameters but only one expression.

Question 35

What is the output of print((lambda x: x ** 2)(5))?

a) 10
b) 25
c) 5
d) 52

Show Answer

Answer: b) 25

Explanation: The lambda function squares its argument. The code defines a lambda that returns x ** 2 and immediately calls it with 5, returning 25.

Question 36

What is the purpose of the return statement?

a) Printing a value
b) Ending the function and optionally returning a value
c) Restarting the function
d) Defining a variable

Show Answer

Answer: b) Ending the function and optionally returning a value

Explanation: return exits the current function and optionally passes a value back to the caller. If no value is specified, it returns None.

Question 37

What is the output of this code?

def func(a, b=2, c=3):
    return a + b + c

print(func(1, c=5))

a) 6
b) 8
c) 9
d) 7

Show Answer

Answer: b) 8

Explanation: Positional argument a=1, keyword argument c=5 (overriding default), and b uses default 2. Total: 1 + 2 + 5 = 8.


Domain 4: Collections & Exceptions (Questions 38–50)

Question 38

What is the output of print(len("Python"))?

a) 5
b) 6
c) 7
d) Error

Show Answer

Answer: b) 6

Explanation: len() returns the number of characters in a string. "Python" has 6 characters.

Question 39

What is the output of this code?

my_list = [1, 2, 3, 4]
print(my_list[1:3])

a) [1, 2]
b) [2, 3]
c) [2, 3, 4]
d) [1, 2, 3]

Show Answer

Answer: b) [2, 3]

Explanation: Slicing [1:3] returns elements from index 1 (inclusive) to index 3 (exclusive). Index 1 = 2, index 2 = 3.

Question 40

What is the output of my_list = [3, 1, 2]; my_list.sort(); print(my_list)?

a) [1, 2, 3]
b) [3, 2, 1]
c) [3, 1, 2]
d) None

Show Answer

Answer: a) [1, 2, 3]

Explanation: list.sort() sorts the list in-place (ascending order) and returns None. The list is modified to [1, 2, 3].

Question 41

Which of the following is mutable?

a) tuple
b) str
c) list
d) int

Show Answer

Answer: c) list

Explanation: Lists are mutable (can be modified after creation). Tuples, strings, and integers are immutable.

Question 42

What is the output of print(tuple([1, 2, 3]))?

a) [1, 2, 3]
b) (1, 2, 3)
c) {1, 2, 3}
d) Error

Show Answer

Answer: b) (1, 2, 3)

Explanation: tuple() converts an iterable (like a list) to a tuple. The result is (1, 2, 3).

Question 43

What is the output of this code?

d = {"a": 1, "b": 2, "c": 3}
print(d["b"])

a) 1
b) 2
c) 3
d) "b"

Show Answer

Answer: b) 2

Explanation: Dictionaries store key-value pairs. Accessing key "b" returns its associated value 2.

Question 44

What is the output of print(set([1, 2, 2, 3, 3, 3]))?

a) [1, 2, 3]
b) {1, 2, 3}
c) {1, 2, 2, 3, 3, 3}
d) Error

Show Answer

Answer: b) {1, 2, 3}

Explanation: A set automatically removes duplicates. Converting [1, 2, 2, 3, 3, 3] to a set gives {1, 2, 3}.

Question 45

What type of error does print(10 / 0) produce?

a) SyntaxError
b) ZeroDivisionError
c) ValueError
d) TypeError

Show Answer

Answer: b) ZeroDivisionError

Explanation: Dividing by zero raises a ZeroDivisionError. It's a runtime error, not a syntax error.

Question 46

What is the purpose of try/except?

a) Defining functions
b) Handling exceptions gracefully
c) Creating loops
d) Defining variables

Show Answer

Answer: b) Handling exceptions gracefully

Explanation: try/except allows you to catch and handle exceptions that occur during execution, preventing the program from crashing.

Question 47

What is the output of this code?

try:
    print(10 / 0)
except ZeroDivisionError:
    print("Cannot divide by zero")

a) Error
b) Cannot divide by zero
c) 10 / 0
d) 0

Show Answer

Answer: b) Cannot divide by zero

Explanation: The try block raises ZeroDivisionError, which is caught by the except clause, printing "Cannot divide by zero".

Question 48

What is the output of this code?

my_list = [1, 2, 3]
my_list.append(4)
print(my_list)

a) [1, 2, 3]
b) [1, 2, 3, 4]
c) [4, 1, 2, 3]
d) [1, 2, 3, [4]]

Show Answer

Answer: b) [1, 2, 3, 4]

Explanation: list.append(x) adds element x to the end of the list. The list becomes [1, 2, 3, 4].

Question 49

What is the output of print("Hello" + 5)?

a) "Hello5"
b) TypeError
c) "Hello 5"
d) 5Hello

Show Answer

Answer: b) TypeError

Explanation: Python does not allow concatenating a string and an integer directly. You need to convert the integer: "Hello" + str(5).

Question 50

What is the output of this code?

data = ["a", "b", "c"]
for i, value in enumerate(data):
    print(i, value)

a) 0 a 1 b 2 c
b) 1 a 2 b 3 c
c) a b c
d) 0 1 2

Show Answer

Answer: a) 0 a 1 b 2 c

Explanation: enumerate() returns pairs of (index, element). Iterating over enumerated data gives (0, "a"), (1, "b"), (2, "c").


How Did You Score?

  • 0–25 correct: Review the PCEP Exam Guide.
  • 26–40 correct: On track. Practice coding more.
  • 41–50 correct: Ready for the exam!

Access all PCEP practice questions →


Related Articles

Bereit, dein Wissen zu testen?

Probiere unsere Übungsprüfungen mit Hunderten von realistischen Fragen aus.

Üben starten →

This site uses essential cookies for Stripe payments. No tracking cookies.