0
0
Pythonprogramming~15 mins

Naming rules and conventions in Python - Mini Project: Build & Apply

Choose your learning style9 modes available
Naming rules and conventions
📖 Scenario: You are helping a friend organize their small library of books using Python. To keep things clear and easy to understand, you will use proper naming rules and conventions for variables.
🎯 Goal: Create variables with correct names following Python naming rules and conventions, then print them to see the results.
📋 What You'll Learn
Create variables with valid Python names
Use lowercase letters and underscores for variable names
Avoid starting variable names with numbers or special characters
Print the variables to show their values
💡 Why This Matters
🌍 Real World
Using clear and correct variable names helps programmers and others understand code easily, just like labeling books in a library.
💼 Career
Good naming conventions are essential for writing clean, maintainable code in any programming job.
Progress0 / 4 steps
1
Create variables with valid names
Create three variables with these exact names and values: book_title with value "Python Basics", author_name with value "Anna Smith", and year_published with value 2023.
Python
Need a hint?

Use only letters, numbers, and underscores. Variable names cannot start with a number.

2
Add a variable with a valid name for book price
Create a variable called book_price and set it to the value 29.99.
Python
Need a hint?

Remember to use lowercase letters and underscores for variable names.

3
Use a for loop with a proper variable name
Use a for loop with the variable info to iterate over the list [book_title, author_name, year_published, book_price] and print each info item.
Python
Need a hint?

Use the variable name info exactly in the for loop.

4
Print a summary using f-string with proper variable names
Print a summary sentence using an f-string: "The book 'Python Basics' by Anna Smith was published in 2023 and costs $29.99." Use the variables book_title, author_name, year_published, and book_price inside the f-string.
Python
Need a hint?

Use print(f"...") with the variable names inside curly braces.