Courseiva

PCEP Computer Programming and Python Fundamentals Practice Question

A developer is writing a Python script and needs to create valid variable names. Which two of the following are valid variable names? (Choose two.)

⚠ Common exam trap

The trap here is assuming that any name without spaces is valid, but identifiers cannot contain hyphens, start with digits, or be reserved keywords.

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

✓

total_amount

Valid Python identifiers must start with a letter or underscore, followed by letters, digits, or underscores, and cannot be keywords. _value and total_amount satisfy these rules, while my-var contains a hyphen, 2ndPlace starts with a digit, and for is a keyword.

Answer analysis

Option-by-option breakdown

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

  • ✗

    2ndPlace

    Why it's wrong here

    Identifiers cannot begin with a digit. 2ndPlace starts with the digit 2, so it is invalid and would raise a SyntaxError. Python requires the first character to be a letter or underscore, followed by letters, digits, or underscores.

  • ✓

    total_amount

    Why this is correct

    total_amount uses only letters and an underscore, and does not start with a digit. It is a valid Python identifier. Underscores are commonly used to separate words in variable names, and this name follows all the rules for valid identifiers.

  • ✗

    my-var

    Why it's wrong here

    The hyphen - is not allowed in Python identifiers; it is interpreted as the subtraction operator. Using my-var would cause a SyntaxError because Python would try to subtract var from my. Valid identifiers may only contain letters, digits, and underscores.

  • ✗

    for

    Why it's wrong here

    for is a reserved keyword in Python used for loops. Keywords cannot be used as identifiers. Attempting to assign to for would cause a SyntaxError. Therefore, it is not a valid variable name, despite being a short word.

  • ✓

    _value

    Why this is correct

    _value starts with an underscore, which is permitted, and contains only letters. It is a valid Python identifier. Underscores are often used to indicate private or special names, but they are legal as the first character and can be used in variable names.

About these practice questions

This PCEP question is part of Courseiva's 482-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam 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.