The Palos Publishing Company

Follow Us On The X Platform @PalosPublishing
Categories We Write About

Create a budget tracker with alerts

Here’s a simple but functional Budget Tracker with Alerts built using Python. It allows users to:

  • Add income and expenses

  • Track balances

  • Set a budget limit

  • Get an alert when the budget is close to or exceeds the limit

python
import datetime class BudgetTracker: def __init__(self, budget_limit): self.transactions = [] self.budget_limit = budget_limit self.balance = 0.0 def add_income(self, amount, description=""): self.transactions.append({ "type": "income", "amount": amount, "description": description, "date": datetime.datetime.now() }) self.balance += amount self._check_alert() def add_expense(self, amount, description=""): self.transactions.append({ "type": "expense", "amount": amount, "description": description, "date": datetime.datetime.now() }) self.balance -= amount self._check_alert() def _check_alert(self): spent = sum(t["amount"] for t in self.transactions if t["type"] == "expense") if spent >= self.budget_limit: print("⚠️ ALERT: Budget limit exceeded!") elif spent >= 0.9 * self.budget_limit: print("⚠️ WARNING: You are close to your budget limit.") def show_summary(self): income = sum(t["amount"] for t in self.transactions if t["type"] == "income") expense = sum(t["amount"] for t in self.transactions if t["type"] == "expense") print(f"Total Income: ${income:.2f}") print(f"Total Expenses: ${expense:.2f}") print(f"Current Balance: ${self.balance:.2f}") print(f"Budget Limit: ${self.budget_limit:.2f}") def show_transactions(self): print("nTransaction History:") for t in self.transactions: print(f"{t['date'].strftime('%Y-%m-%d %H:%M:%S')} - {t['type'].capitalize()}: ${t['amount']:.2f} - {t['description']}") # Example usage: tracker = BudgetTracker(budget_limit=1000) tracker.add_income(1500, "Salary") tracker.add_expense(200, "Groceries") tracker.add_expense(600, "Rent") tracker.add_expense(150, "Utilities") tracker.show_summary() tracker.show_transactions()

Features:

  • Budget limit alert when expenses reach or exceed 90% of the limit.

  • Easy summary of income, expenses, and balance.

  • Transaction history with timestamps.

Would you like a web or mobile version of this tool as well (e.g., HTML/JS or React Native)?

Share this Page your favorite way: Click any app below to share.

Enter your email below to join The Palos Publishing Company Email List

We respect your email privacy

Categories We Write About