Courseiva
Computer Programming and Python FundamentalsmediumMultiple ChoiceObjective-mapped

PCEP Computer Programming and Python Fundamentals Practice Question

A programmer writes the following code:

if x > 5:
print('Greater')

What is the most likely cause of an IndentationError?

⚠ Common exam trap

The PCEP exam often tests that candidates understand IndentationError is a syntax-level error caused by incorrect spacing, not by missing colons or undefined variables, which produce different error types.

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

The print statement is not indented.

In Python, the colon at the end of an if statement signals the start of an indented block. The print statement must be indented (typically 4 spaces) to be part of that block. Without indentation, Python raises an IndentationError because it expects a suite of statements under the if clause.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • The print statement is not indented.

    Why this is correct

    Requires indentation.

  • The comparison operator is wrong.

    Why it's wrong here

    '>' is valid.

  • The variable x is undefined.

    Why it's wrong here

    Would cause NameError, not IndentationError.

  • The colon after the condition is missing.

    Why it's wrong here

    Colon is present.

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 →

How Courseiva writes practice questions · Editorial policy

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.