PCEP Computer Programming and Python Fundamentals Practice Question
Which TWO of the following are valid variable names in Python? (Choose Two)
⚠ Common exam trap
The PCEP exam often tests the rule that hyphens are invalid in variable names (tricking candidates who confuse them with underscores) and that keywords like `class` are reserved, even though they look like valid identifiers.
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
✓
_myVar
In Python, variable names can start with an underscore, and `_myVar` follows the naming rules: it begins with a letter or underscore, contains only letters, digits, or underscores, and is not a reserved keyword. Underscore-prefixed names are commonly used for internal or private variables by convention.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
my-var
Why it's wrong here
Hyphen is not allowed; use underscore instead.
- ✓
_myVar
Why this is correct
Underscore at start is allowed.
- ✗
2ndValue
Why it's wrong here
Cannot start with a digit.
- ✗
class
Why it's wrong here
class is a reserved keyword.
- ✓
my_var
Why this is correct
Underscore inside is allowed.
Go deeper
Related to this question
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 →
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.