python variables naming conventions assignment rules 2024 Challenge
Read the problem description and solve the challenge in the workspace.
Coding Challenge: Cafe Inventory Tracker
Problem Description Imagine you are building a simple inventory and management tracker for a local cafe. A previous developer started creating digital boxes (variables) to store the daily stock of coffee beans the daily profit, and the manager's secret alarm code. Unfortunately, they broke Python's strict grammar rules and completely ignored the community PEP 8 style guidelines!
Your task is really towards fix the variable names so the program doesn't crash. You've got to apply proper formatting, mark a secret code as a private variable, and correct the spacing around assignment operators.
Difficulty Level: Beginner
Input & Output Specifications * Input: Three improperly formatted variable assignments (provided in the starter code). * Output: Three correctly formatted variables that use standard naming conventions, proper operator spacing. Private variable indicators where applicable.
Starter Code Boilerplate
# Fix the following variables based on Python syntax rules and PEP 8 guidelines:
coffee beans= 50
daily Profit =250.75
secret alarm code= 9876
Hints
* Snake Case: Variable names can't contain spaces. If you want to use multiple words, you've got to write them in all lowercase letters and separate the words with underscores (_).
* Private Variables: To signal to other programmers that a variable is a secret or "non-public", you should simply put exactly one leading underscore at the very beginning of name (e.g., _secret_password).
* The Operator Rule (PEP 8): You should always have exactly one space on both sides of the binary operator like the equals sign (=).
Test Cases
Test Case 1 (Syntax Check)
* Input: Run a cleaned-up Python script.
* Expected Output: The program should just run smoothly without throwing the SyntaxError.
Test Case 2 (Variable Verification) * Input:
print(coffee_beans)
print(daily_profit)
print(_secret_alarm_code)
- Expected Output:
50
250.75
9876