Courseiva

PCEP Computer Programming and Python Fundamentals Practice Question

A Python program needs to store the integer value 42 in a variable named count. Which line of code correctly assigns this value?

⚠ Common exam trap

Watch out — candidates often confuse the assignment operator = with the equality operator ==, which performs a comparison rather than storing a 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

✓

count = 42

The assignment operator = stores a value in a variable. In this scenario, count = 42 correctly binds the name count to the integer 42. The other options either compare, reverse the assignment, or use an operator that is not valid as a standalone statement.

Answer analysis

Option-by-option breakdown

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

  • ✗

    count == 42

    Why it's wrong here

    This uses the equality comparison operator ==, which checks if count already equals 42 and returns a Boolean, but does not assign the value. It would raise a NameError if count is undefined. The scenario requires assignment, not comparison.

  • ✗

    42 = count

    Why it's wrong here

    This attempts to assign the value of count to the literal 42, which is invalid because the left side of an assignment must be a target like a variable name, not a literal. Python raises a SyntaxError. It reverses the intended direction of assignment.

  • ✓

    count = 42

    Why this is correct

    The single equals sign = is the assignment operator in Python. It binds the name count to the integer object 42. This is the standard and correct way to store a value in a variable, satisfying the requirement exactly.

  • ✗

    count := 42

    Why it's wrong here

    The walrus operator := is used for assignment expressions within larger expressions, not as a standalone statement. Using it alone like this is a syntax error. It is not the correct way to assign a variable in a simple statement.

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 →

How Courseiva writes practice questions · Editorial policy

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.