Courseiva

PCEP Practice Question: Data Types, Variables, Basic I/O and Operators

Which of the following is NOT a valid variable name in Python?

⚠ Common exam trap

The PCEP exam often tests the rule that variable names cannot start with a digit, knowing that candidates may mistakenly think digits are allowed anywhere or that underscores are not valid starting characters.

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

✓

2nd_var

Python variable names cannot start with a digit. The name '2nd_var' begins with '2', which violates Python's identifier naming rules. Valid variable names must start with a letter (a-z, A-Z) or an underscore (_), and can be followed by letters, digits, or underscores.

Answer analysis

Option-by-option breakdown

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

  • ✗

    _myvar

    Why it's wrong here

    _myvar is valid Python: a leading underscore is permitted and is conventionally used for internal or private names. The question asks for the invalid name, so this option does not qualify. It is tempting to reject because of the leading underscore, but only a leading digit would actually make an identifier invalid.

  • ✗

    myVar2

    Why it's wrong here

    myVar2 is a perfectly valid Python identifier: it starts with a letter and contains only letters and digits. The question asks which name is NOT valid, so this option cannot be the answer. It is tempting because the trailing digit looks unusual, yet digits are permitted after the first character.

  • ✓

    2nd_var

    Why this is correct

    Python identifiers cannot begin with a digit, so 2nd_var raises a SyntaxError at parse time. Valid names must start with a letter or underscore, then contain letters, digits or underscores, making this the only invalid option.

  • ✗

    my_var

    Why it's wrong here

    my_var is valid Python: the underscore is a legal identifier character and the name begins with a letter. Since the question seeks the invalid name, this option is not it. It may appear suspect because of the underscore, but underscores are conventional in Python naming and carry no restriction.

About these practice questions

One of 482 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.