PCEP Computer Programming and Python Fundamentals Practice Question
Which TWO of the following are valid variable names in Python?
⚠ Common exam trap
The PCEP exam often tests the rule that hyphens are invalid in variable names, as candidates may confuse them with underscores or assume they are allowed like in other languages (e.g., Lisp or some shell scripting).
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
Options A (_myVar) and D (my_var) are the two correct variable names. Option B (my Var) is invalid because it contains a space, option C (my-var) contains a hyphen which is not allowed, and option E (2ndPlace) starts with a digit.
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 this is correct
_myVar is valid: it starts with an underscore and contains only letters and underscores.
- ✗
my Var
Why it's wrong here
myVar is valid: it starts with a letter and contains only letters.
- ✗
my-var
Why it's wrong here
my-var is invalid: hyphens are not allowed in Python identifiers.
- ✓
my_var
Why this is correct
my_var is valid: it consists of letters and an underscore.
- ✗
2ndPlace
Why it's wrong here
2ndPlace is invalid: variable names cannot start with a digit.
Go deeper
Related to this question
About these practice questions
This PCEP question is part of Courseiva's 498-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 →
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.