Bird
0
0

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

easy📝 Conceptual Q11 of 15
Python - Variables and Dynamic Typing
Which of the following is a valid variable name in Python?
Amy-variable
B2ndVariable
Cmy_variable
Dmy variable
Step-by-Step Solution
Solution:
  1. Step 1: Check the first character of each name

    Python variable names must start with a letter or underscore, not a number or special character.
  2. Step 2: Identify invalid characters

    Names cannot contain spaces or hyphens. Only letters, digits, and underscores are allowed.
  3. Final Answer:

    my_variable -> Option C
  4. Quick Check:

    Valid variable name = my_variable [OK]
Quick Trick: Variable names start with letter/underscore, no spaces or hyphens [OK]
Common Mistakes:
MISTAKES
  • Starting variable name with a number
  • Using hyphens instead of underscores
  • Including spaces in variable names

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes