Python Variable Naming Quiz
Question
Which of the following is a valid Python variable name?
Hint
Variable names must start with a letter or underscore, and cannot contain hyphens or be keywords.
Explanation
player_score is valid: it starts with a letter, contains only letters and an underscore. 2nd_place is invalid because names cannot start with a digit. first-name is invalid because hyphens are not allowed (Python reads it as subtraction). class is invalid because it is a reserved Python keyword.
Related Resources
Related Lessons
- Python Variables
Learn how variables work in Python.
Related Cheatsheets
- Python Cheatsheet
Quick reference for Python variable naming rules.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.