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:
Step 1: Check allowed characters in variable names
Python variable names can contain letters, digits (not as first character), and underscores only.
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.
Final Answer:
user_name -> Option D
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
Master "Variables and Dynamic Typing" in Python
9 interactive learning modes - each teaches the same concept differently