Learning Python syntax is one thing. Being able to trace a short program and explain exactly why it produces a particular result takes practice.
If you’re preparing for PCEP, working through small questions can help you identify concepts that need more attention.
Below are five Python fundamentals questions with explanations. Try answering each one before running the code.
1. Division: what is the difference between / and //?
What does this code print?
print(9 / 2)
print(9 // 2)
print(-9 // 2)
Answer:
4.5
4
-5
The / operator performs true division. Dividing these two integers produces a floating-point result.
The // operator performs floor division: it rounds the quotient down towards negative infinity.
That distinction matters for negative numbers. Since -9 / 2 is -4.5, floor division produces -5, rather than -4.
Takeaway: Floor division does more than remove the decimal part.
2. What values does range() generate?
What does this code print?
total = 0
for number in range(2, 8, 2):
total += number
print(total)
Answer:
12
The arguments are:
range(start, stop, step)
The starting value is included, but the stopping value is excluded.
Here, the loop uses 2, 4, and 6:
2 + 4 + 6 = 12
Takeaway: Write out the values generated by range() before tracing the rest of a loop.
3. Does assigning a list create a copy?
What does this code print?
original = [10, 20, 30]
other = original
other[1] = 99
print(original)
Answer:
[10, 99, 30]
The assignment:
other = original
does not create a new list. Both variable names refer to the same list, so modifying it through other is visible through original.
To create a shallow copy, you could use:
other = original.copy()
For this list of integers, changing an element in that copy would leave the original list unchanged.
Takeaway: Distinguish between assigning another reference to an object and copying the object.
4. How does Boolean precedence affect a condition?
What does this code print?
print(True or False and False)
print((True or False) and False)
Answer:
True
False
The and operator has higher precedence than or.
The first expression is grouped as:
True or (False and False)
Its result is True.
In the second expression, parentheses change the grouping:
(True or False) and False
That becomes True and False, producing False.
Takeaway: Understand precedence, but use parentheses when they make your intention easier to read.
5. Does print() return the value it displays?
What does this code print?
def add(a, b):
print(a + b)
result = add(2, 3)
print(result)
Answer:
5
None
Calling add(2, 3) displays 5.
However, the function has no explicit return statement, so it returns None. That is the value assigned to result.
To return the sum instead, write:
def add(a, b):
return a + b
Takeaway: Displaying a value and returning a value are separate actions.
How to make practice questions more useful
Getting an answer right is only the first step. For each question:
- Predict the output without running the code.
- Explain your reasoning in plain English.
- Run the code and compare the result.
- Change one detail and predict what happens next.
For example, change the step in range(), copy a list before modifying it, or replace print() with return.
If your prediction is wrong, record the underlying concept you missed. A short list of recurring mistakes gives you a focused revision plan.
When preparing for PCEP, also check the official exam syllabus for the version you intend to take. Use practice questions alongside writing and running your own Python programs.
Free practice resource
I create Python learning resources through AM Academy, and I’m sharing my PCEP practice papers for free: https://www.udemy.com/course/python-pcep-30-03-certification-practice-tests-2026/?couponCode=FREE-COURSE-PCEP.
I’m the creator of this resource; it is independent preparation material and is not affiliated with or endorsed by the Python Institute.
Which of these concepts did you find trickiest when you started learning Python?
Top comments (0)