Bird
0
0

Which of the following variable names follows Python's naming rules?

easy📝 Conceptual Q1 of 15
Python - Variables and Dynamic Typing
Which of the following variable names follows Python's naming rules?
Auser-name
B2ndUser
Cuser name
Duser_name
Step-by-Step Solution
Solution:
  1. Step 1: Check allowed characters in variable names

    Python variable names can contain letters, digits (not as first character), and underscores only.
  2. Step 2: Evaluate each option

    user_name uses letters and underscore correctly. 2ndUser starts with a digit, which is invalid. user-name contains a hyphen, which is not allowed. user name contains a space, which is invalid.
  3. Final Answer:

    user_name -> Option D
  4. Quick Check:

    Valid variable name = user_name [OK]
Quick Trick: Variable names start with letter or underscore, no spaces or hyphens [OK]
Common Mistakes:
MISTAKES
  • Starting variable name with a digit
  • Using spaces in variable names
  • Using special characters like hyphens

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes