Which of these is the best variable name for storing a user's age according to Python naming conventions?
easy📝 Conceptual Q2 of 15
Python - Variables and Dynamic Typing
Which of these is the best variable name for storing a user's age according to Python naming conventions?
Auser age
BUserAge
Cuser-age
Duser_age
Step-by-Step Solution
Solution:
Step 1: Understand Python naming conventions
Python uses snake_case for variable names, which means lowercase letters with underscores between words.
Step 2: Compare options
user_age uses snake_case correctly. UserAge uses CamelCase, which is usually for class names. Options C and D contain invalid characters (hyphen and space).