PCEP Computer Programming and Python Fundamentals Practice Question
A developer writes the following code:
x = 5
if x > 3:
print('A')else:
print('B')
print('C')What is the output?
⚠ Common exam trap
The trap here is assuming that all indented lines run or that the else always executes, when in fact only one branch of an if-else runs and the trailing print is unconditional.
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
✓
A C
With x equal to 5, the condition x > 3 is True, so the if block prints 'A' and the else block is skipped. The final print('C') is outside the conditional structure and always executes. The output is therefore 'A' followed by 'C' on separate lines.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
A B C
Why it's wrong here
Only one branch of an if-else executes. Because x > 3 is True, the else block does not run, so 'B' is not printed. The final print('C') is outside the if-else and always executes, but 'B' should not appear.
- ✗
B C
Why it's wrong here
The condition x > 3 evaluates to True for x = 5, so the if branch runs and prints 'A'. The else branch is skipped. Printing 'B' would require the condition to be False, which is not the case here.
- ✗
A
Why it's wrong here
The print('C') statement is not indented under the if or else; it is at the same indentation level as the if statement, so it executes regardless of the condition. Therefore 'C' is also printed, making the output 'A' and 'C'.
- ✓
A C
Why this is correct
Since x is 5, the condition x > 3 is True, so the if block prints 'A'. The else block is skipped. After the if-else structure, the indented level returns to the top, so print('C') runs unconditionally, producing 'A' then 'C' on separate lines.
Go deeper
Related to this question
About these practice questions
Courseiva writes every PCEP question from scratch — 482 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →
JA
Written and reviewed by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
Last reviewed September 2026 · checked against the official Python Institute exam blueprint
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.