Python Project
Python Project
BUDGET TRACKER
1. Data Structures:
Dictionaries:
o To store income and expense categories with their corresponding
amounts.
o Example: income = {'salary': 3000, 'freelance':
500}
Lists:
o To store a list of transactions, each represented as a dictionary.
o Example: transactions = [{'date': '2023-11-25',
'category': 'food', 'amount': 20}, {'date':
'2023-11-26', 'category': 'rent', 'amount':
800}]
2. Input/Output Operations:
User Interface:
o Text-Based: Use input() and print() functions for simple
interactions.
o Graphical User Interface (GUI): Employ libraries like Tkinter or
PyQt for more user-friendly interfaces.
Calculations:
o Calculate total income, total expenses, and remaining balance.
o Calculate average spending per category.
o Identify spending trends over time.
Data Visualization:
o Visualize income and expense trends, category-wise spending, and
savings progress.
4. Core Functionality:
Add/Edit Transactions:
o Allow users to add or edit transactions with details like date,
category, and amount.
Categorize Expenses:
o Implement a categorization system for expenses (e.g., food,
housing, transportation).
Set Budgets:
o Allow users to set monthly or yearly budget limits for different
categories.
Generate Reports:
o Generate detailed reports on income, expenses, savings, and
spending trends.
SOURCE CODE
class BudgetTracker:
users=[]
def __init__(self,name,income):
self.totalbal = income
self.expense = {}
print("user created successfully")
def addExpense(self,title,amount):
self.totalbal-=amount
self.expense.update({title:amount})
print("expense added successfully")
print("remaining balance:",self.totalbal)
def addBalance(self,income):
self.totalbal+=income
self.currentBalance()
def currentBalance(self):
print("Current balance:",self.totalbal)
def allExpenses(self):
totalAmount=0
for title,amount in self.expense.items():
print(title ,":",amount)
totalAmount += amount
print("total expense is:",totalAmount)
if __name__=="__main__":
flg=1
while(flg):
print("""
1. create user
2. add expense
3. add Balalce
4. current Balance
5. See your all expenses
6. exit """)
button = int(input("Select option.. "))
if button == 1:
name = input("Enter your name: ")
income = int(input("Enter your income: "))
user = BudgetTracker(name,income)
BudgetTracker.users.append(user)
elif button ==2:
title = input("Enter title of the expense: ")
amount = int(input("Enter amount: "))
user.addExpense(title,amount)
Enhancements:
File I/O: Save and load data to/from files for persistent storage.
Categorization: Implement a more detailed categorization system for
expenses.
Visualization: Use libraries like Matplotlib or Seaborn to visualize
income, expenses, and savings.
User Interface: Create a more user-friendly interface using a GUI library
like Tkinter or PyQt.
Security: If storing sensitive financial data, consider encryption
techniques.
Error Handling: Implement error handling to catch invalid inputs and
prevent crashes.
CONCLUSION
This Python-based budget tracker provides a solid foundation for managing
personal finances. By utilizing dictionaries and lists to store income and
expense data, the program offers a flexible and efficient way to track financial
transactions.
Key Features:
Income and Expense Tracking: Users can easily add income sources
and categorize expenses.
Balance Calculation: The program accurately calculates the remaining
balance by subtracting total expenses from total income.
User-Friendly Interface: The menu-driven interface simplifies
interaction with the program.
Potential Enhancements:
Data Persistence: Implement file I/O to save and load data, allowing for
long-term tracking.
Advanced Categorization: Introduce a more detailed categorization
system for expenses to gain deeper insights into spending habits.
Goal Setting and Tracking: Allow users to set financial goals and
monitor progress towards them.
Security: Implement encryption techniques to protect sensitive financial
information.
Error Handling: Incorporate robust error handling to prevent
unexpected crashes and provide informative error messages.