BUDS PUBLIC SCHOOL
DUBAI
Session 2024-25
INFORMATICS PRACTICES
PROJECT
ON
Personal Expenses
Calculator
SUBMITTED BY:
Sam Emirik Micheal
Class: XII B
ACKNOWLEDGMENT
I would like to express my heartfelt gratitude
to all those who have supported and guided
me.
I am thankful to my IP teacher,
Mrs.Jessy, for her guidance, encouragement,
and constructive feedback throughout this
project.
I am also sincerely grateful to our
Supervisor, Ms. Lorna Daniel and our
Principal, Mr. Donald Weilson,who made this
project possible.
Their encouragement and leadership have
always motivated me to strive for excellence
in all my endeavors.
This project would not have been successful
without the contributions and guidance of
the individuals,friends,family, and I am truly
thankful for their support.
INDEX
S.no Topic Pg.no
1 Objective
2 Software
and
hardware
requirement
3 The theory
and concept
Implemented
4 Python
Code
5 Output
6 Conclusion
7 Bibliography
OBJECTIVE
Aim:To create a tangible and useful IP
application
● Understanding Data: Develop a
comprehensive understanding of the
dataset
● Data collection: Storing Data in a CSV
file
● Importing Data in Pandas: Import data
from a CSV file into a DataFrame
● Data Analysis: Analyze data using
Python Pandas Library
● Data Visualization: Generate
appropriate charts and graphs to
visualize data
SOFTWARE AND HARDWARE
REQUIREMENTS
Software:
● Visual Studio Code
● Microsoft Excel
Hardware:
● 1.6 GHz or faster processor
● 1 GB of RAM
THEORY AND CONCEPTS
IMPLEMENTED
● Python pandas library
● CSV files
● Python numpy library
● Python matplotlib.pyplot library
PYTHON CODE
import csv
from datetime import datetime
import matplotlib.pyplot as plt
def load_expenses(expenses):
try:
with open(expenses, mode='r') as file:
reader = csv.DictReader(file)
return list(reader)
except FileNotFoundError:
print(f"{expenses} not found. Creating a new file...")
return []
def view_expenses(expenses):
if not expenses:
print("No expenses to display.")
return
print("Date | Category | Description | Amount")
print("-" * 50)
for expense in expenses:
print(f"{expense['Date']} | {expense['Category']:<10} | {expense['Description']:<15} |
${float(expense['Amount']):.2f}")
def add_expense(filename, expenses):
date = input("Enter date (YYYY-MM-DD): ")
category = input("Enter category (e.g., Food, Transport): ")
description = input("Enter description: ")
amount = input("Enter amount: ")
new_expense = {"Date": date, "Category": category, "Description": description,
"Amount": amount}
expenses.append(new_expense)
with open(filename, mode='w', newline='') as file:
writer = csv.DictWriter(file, fieldnames=["Date", "Category", "Description", "Amount"])
writer.writeheader()
writer.writerows(expenses)
print("Expense added successfully!")
def calculate_totals(expenses):
if not expenses:
print("No expenses to calculate.")
return
total = sum(float(expense["Amount"]) for expense in expenses)
print(f"Total Expenses: ${total:.2f}")
def generate_graphs(expenses):
if not expenses:
print("No expenses to generate graphs.")
return
print("\nGraph Options:")
print("1. Total Expenses by Category")
print("2. Expenses Over Time (Line Graph)")
print("3. Exit to Main Menu")
choice = input("Enter your choice: ")
if choice == "1":
total_by_category = {}
for expense in expenses:
category = expense["Category"]
amount = float(expense["Amount"])
total_by_category[category] = total_by_category.get(category, 0) + amount
categories = list(total_by_category.keys())
totals = list(total_by_category.values())
plt.figure(figsize=(8, 6))
plt.pie(totals, labels=categories, autopct="%1.1f%%", startangle=140)
plt.title("Total Expenses by Category")
plt.show()
elif choice == "2":
expenses.sort(key=lambda x: datetime.strptime(x["Date"], "%Y-%m-%d"))
dates = [expense["Date"] for expense in expenses]
amounts = [float(expense["Amount"]) for expense in expenses]
plt.figure(figsize=(10, 6))
plt.plot(dates, amounts, marker="o", linestyle="-", color="b")
plt.xticks(rotation=45)
plt.title("Expenses Over Time")
plt.xlabel("Date")
plt.ylabel("Amount ($)")
plt.grid(True)
plt.tight_layout()
plt.show()
elif choice == "3":
return
else:
print("Invalid choice. Returning to main menu.")
def main():
filename = "expenses.csv"
expenses = load_expenses(filename)
while True:
print("\nExpense Tracker")
print("1. View Expenses")
print("2. Add Expense")
print("3. Calculate Totals")
print("4. Generate Graphs")
print("5. Exit")
choice = input("Enter your choice: ")
if choice == "1":
view_expenses(expenses)
elif choice == "2":
add_expense(filename, expenses)
elif choice == "3":
calculate_totals(expenses)
elif choice == "4":
generate_graphs(expenses)
elif choice == "5":
break
else:
print("Invalid choice. Please try again.")
if __name__ == "__main__":
main()
OUTPUT
-Main Menu
-View Expenses(Option-1)
-Add Expense(Option-2)
-Calculate Totals(Option-3)
-Generate Graphs(Option-4)
CONCLUSION
This project focuses on tracking and
visualizing weekly expenses by recording
details such as date, category, description,
and amount. It provides clear visualizations
through line graphs to track total expenses
over time and pie charts to show how
spending is distributed across categories.
The main purpose is to offer an organized
way to view and total expenses, helping
users better understand their spending
patterns. Overall, this project simplifies the
process of tracking weekly expenses and
provides useful insights through visual data
representation.
BIBLIOGRAPHY
Websites:
youtube.com
python
NCERT:
Textbook