PCEP Practice Question: Data Types, Variables, Basic I/O and Operators
A function is designed to return False if a number is not divisible by 2. Which of the following return statements correctly implements this logic?
⚠ Common exam trap
Test-takers frequently confuse the condition for divisibility (n % 2 == 0) with the condition for non-divisibility (n % 2 != 0), leading them to select an option that returns the opposite boolean value.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
return n % 2 == 0
The function must return False when the number is not divisible by 2. The expression `n % 2 == 0` evaluates to True when n is even (divisible by 2) and False when n is odd (not divisible by 2), directly matching the required logic.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
return n % 2 != 0
Why it's wrong here
Incorrect. This returns True when not divisible, not False.
- ✗
return n % 2 == 1
Why it's wrong here
Incorrect. This returns True only for odd numbers, but for non-divisible (odd) it returns True, not False.
- ✗
return not n % 2 == 0
Why it's wrong here
Incorrect. This returns True when n is not divisible (opposite of required).
- ✓
return n % 2 == 0
Why this is correct
Correct. Returns True if divisible, False otherwise, matching the requirement.
Go deeper
Related to this question
About these practice questions
One of 498 original PCEP practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
Same concept, more angles
1 more way this is tested on PCEP
These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.
Variation 1. A program checks divisibility. Which condition correctly determines if a number n is divisible by 7?
hard- A.n / 7 == 0
- B.n // 7 == 0
- ✓ C.n % 7 == 0
- D.n % 7 != 0
Why C: The modulo operator (%) returns the remainder of the division of n by 7. If the remainder is 0, then n is exactly divisible by 7. This is the standard way to test divisibility in Python.
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This PCEP practice question is part of Courseiva's free Python Institute certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the PCEP exam.