Choosing Descriptive Variable Names

Carson West

Variable Naming Conventions

Choosing Descriptive Variable Names

This note covers best practices for choosing descriptive variable names in Python. The goal is to write code that is readable and maintainable.

Key Principles:

Examples:

Good:

customer_name = "Alice Smith"
order_total = 150.50
product_prices = [10.99, 25.00, 5.75
is_logged_in = True

Bad:

n = "Alice Smith"  # What does 'n' represent?
t = 150.50        # Too cryptic
p = [10.99, 25.00, 5.75 #What is p?
l = True         # What does 'l' mean?

Further Considerations: