Budget Tracker Program

Budget Tracker Program

Python Coding Practice

Write a Python program to create a household budget tracker. The program should take the following fixed expenses as input:

– Electricity: $95
– Netflix: $15
– Phone: $45
– Gasoline: $135
– Supermarket: $660
– Car insurance: $420
– Rent: $1100

Additionally, the program should ask the user to input any additional expenses or income. To indicate whether the input amount is an expense or income:

  • If the first character is “I”, consider it as income and add it to the final balance.
  • If the first character is “E”, consider it as an expense.

The program should keep prompting the user to enter new inputs until they choose to exit. Finally, the program should display a table showing all expenses and income, along with the final balance. Any expenses or income entered by the user should be labeled as “others”.

Use the following formula to calculate the final balance:
Balance = (sum(Income) – (sum(expenses) + sum(fixed expenses)))

See here for additional Python coding practice.

Expected output

budget tracker program in python


# Initialize fixed expenses
fixed_expenses = {
    "Electricity": 95,
    "Netflix": 15,
    "Phone": 45,
    "Gasoline": 135,
    "Supermarket": 660,
    "Car insurance": 420,
    "Rent": 1100

# Initialize variables for income, expenses, and balance
income = []
expenses = []

# Function to calculate the balance
def calculate_balance(income, expenses, fixed_expenses):
    total_fixed_expenses = sum(fixed_expenses.values())
    return sum(income) - (sum(expenses) + total_fixed_expenses)

# Loop to keep asking the user to enter new inputs
while True:
    user_input = input("Enter the amount and specify if it's an income (I) or an expense (E), or enter 'exit' to finish: ")
    if user_input.lower() == "exit":
        amount = int(user_input[1:])
        if user_input[0].upper() == "I":
        elif user_input[0].upper() == "E":
            print("Invalid input. Please start with 'I' for income or 'E' for expense.")

# Calculate the final balance
balance = calculate_balance(income, expenses, fixed_expenses)

# Print the table with all expenses and income as well as the final balance
for expense, amount in fixed_expenses.items():
print("Other Income\t\t", sum(income))
print("Other Expenses\t\t", sum(expenses))
print("\nFinal Balance:", balance)


We will be happy to hear your thoughts

Leave a reply

Python and Excel Projects for practice
Register New Account
Shopping cart