Back to Certified Entry-Level Python Programmer PCEP questions

Scenario-based practice

Hard Difficulty Questions

Practise Certified Entry-Level Python Programmer PCEP practice questions — original exam-style scenarios covering every exam domain, with detailed explanations, wrong-answer analysis, and common exam traps.

19
scenario questions
PCEP
exam code
Python Institute
vendor

Scenario guide

How to approach hard difficulty questions

These are the questions most candidates get wrong. They require connecting multiple concepts, reading tricky output, or knowing edge-case behaviour that isn't on most study cards. Practising them trains you to operate under uncertainty — a necessary skill on the real exam.

Quick answer

Hard Difficulty Questions questions test whether you can apply the concept in context, not just recognise a definition.

How the topic appears in realistic exam-style scenarios.

Which detail in the question changes the correct answer.

How to eliminate plausible but wrong options.

How to connect the question back to the wider exam objective.

Related practice questions

Related PCEP topic practice pages

Scenario questions usually connect to one or more exam topics. Use these links to review the underlying concepts behind the scenario.

Practice set

Practice scenarios

Which THREE of the following statements about Python data types are correct? (Choose three.)

Question 2hardmultiple choice
Full question →

A developer writes the following code snippet:

for i in range(3):
    for j in range(2):
        if i == j:

break else:

print(i, 'outer')

What is the output?

Question 3hardmultiple choice
Full question →

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

Question 4hardmultiple choice
Full question →

Given the code: a = [1, 2, 3]; b = a; b.append(4). What is the value of a?

Question 5hardmultiple choice
Full question →

A user enters 'Alice' for name and '30' for age. What is the output?

Exhibit

Refer to the exhibit.

name = input('Enter name: ')
age = input('Enter age: ')
print(name + ' is ' + age + ' years old.')

A Python program is designed to process user input and store results in a dictionary. The code uses the statement: my_dict[user_key] = value. Under which condition will this statement raise a TypeError?

Question 7hardmultiple choice
Full question →

A script uses the // operator with negative numbers. For example, -7 // 2 returns -4. The developer expected -3. Which statement best explains this behavior?

Question 8hardmultiple choice
Full question →

A developer needs to store a large collection of unique user IDs (integers) and quickly check if a new ID already exists. Which data type is most appropriate for this task?

Question 9hardmultiple choice
Full question →

A developer runs main.py and gets True. They then modify config.py by adding `allowed_ports.append(22)` and run main.py again without restarting the interpreter. What is the output?

Exhibit

Refer to the exhibit.

# config.py
allowed_ports = [80, 443, 8080]

def check_port(port):
    if port in allowed_ports:
        return True
    else:
        return False

# main.py
from config import check_port
print(check_port(80))
Question 10hardmulti select
Full question →

Which TWO of the following code snippets will print the numbers 0, 1, 2, 3, 4?

Question 11hardmultiple choice
Full question →

Given the code: x = [1, 2, 3] y = x y.append(4)

print(x)

What is the output?

Question 12hardmultiple choice
Full question →

A server logs are stored as a list of tuples: `logs = [('2024-01-10', 'INFO', 'Started'), ('2024-01-10', 'ERROR', 'Disk full')]`. A developer wants to count how many ERROR logs exist. Which code snippet correctly counts them?

A Python script processes a list of tuples representing coordinates: `points = [(1,2), (3,4), (5,6)]`. The developer wants to create a dictionary mapping each coordinate to its distance from origin. Which code correctly creates the dictionary?

Which THREE of the following are valid ways to handle an exception in Python?

Question 15hardmultiple choice
Full question →

A script calculates total cost: price = 49.95, quantity = 3, tax_rate = 0.08. The developer writes: total = price * quantity * (1 + tax_rate). The result is printed as 161.838. Which best practice is being violated?

Question 16hardmultiple choice
Full question →

What is the result of the expression: print(2 ** 3 ** 2) ?

Question 17hardmultiple choice
Full question →

Refer to the exhibit. What is the output of Line C?

Exhibit

def func(a, b, c=10, d=20):
    return a + b + c + d

print(func(1, 2, 3, 4))  # Line A
print(func(1, 2, 3))     # Line B
print(func(1, 2))        # Line C
Question 18hardmultiple choice
Read the full NAT/PAT explanation →

A developer is troubleshooting a loop that terminates earlier than expected. The code is: i = 0; while i < 5: if i == 3: break; print(i); i += 1. What is the output?

Which TWO of the following are true about Python's if statement?

These PCEP practice questions are part of Courseiva's free Python Institute certification practice question bank. Courseiva provides original exam-style PCEP questions with detailed explanations, topic-based practice, mock exams, readiness tracking, and study analytics.