Exercise: Enhanced Monthly Budget Planner
Objective:
Create a simple monthly budget planner that helps users track their income and expenses.
Steps:
-
User Information:
- Ask the user for their name and store it in a variable called
name
. - Ask the user for their total monthly income and store it in a variable called
monthly_income
.
- Ask the user for their name and store it in a variable called
-
Monthly Expenses:
- Ask the user for their monthly rent and store it in a variable called
rent
. - Ask the user for their monthly groceries expense and store it in a variable called
groceries
. - Ask the user for their monthly transportation cost and store it in a variable called
transportation
. - Ask the user for any other monthly expenses (e.g., entertainment) and store it in a variable called
other_expenses
.
- Ask the user for their monthly rent and store it in a variable called
-
Calculate Total Expenses:
- Create a variable to calculate the total monthly expenses by adding together rent, groceries, transportation, and other expenses.
-
Calculate Remaining Balance:
- Create a variable to calculate the remaining balance after subtracting total expenses from monthly income.
-
Check Budget Status:
- Use if-elif-else statements to evaluate the remaining balance and provide feedback:
- If remaining_balance is greater than 500,
print:“Greatjob,[name]! Youhave[remaining_balance] left. Consider saving or investing some of it!” - If remaining_balance is between 0and500,
print: “Nice work, [name]! You have $[remaining_balance] left. This is a good amount for savings or leisure.” - If remaining_balance is less than 0,
print: “Oops, [name]! You are over budget by $[abs(remaining_balance)]. Consider cutting back on expenses.”
- If remaining_balance is greater than 500,
- Use if-elif-else statements to evaluate the remaining balance and provide feedback: