- 28th Jun 2024
- 17:37 pm
In this assignment you are only able to use the standard python library. No third parties library allowed. Our expert will make you learn how to utilize various data structures, implement iteration and conditionals, handle exceptions, and write unit tests, ensuring your code is comprehensive and accessible for users with varying levels of Python knowledge. The program should be able to sort by category, month, and year, dollar amount. The program should also be able to sum the transactions amount by category, month/year.
1. The application must include at least the minimum number of each of the following:
- 4 container types (list, tuple, set AND dictionary) that are used by the application
- 1 iteration type (for, while)
- 1 conditional (if)
- 1 try block with an else condition
- 1 user-defined function that accepts parameters/arguments and/or returns a value.
- 1 input and/or output file (include input data with your project)
- 1 user-defined class. The class must be imported by your main program from a separate file and have the following required structures.
- at least 1 private and 2 public self class attributes
- at least 1 private and 2 public class methods that take arguments, return values and are used by your program
- an init() class method that takes at least 1 argument a repr() or str() class method
- a magic class method (not one of the methods listed above)
2. Provide 2 unit tests that prove two of your public class methods work as expected. The tests should evaluate results using assert statements.
Simple Expense Tracker Program Using Python - Get Assignment Solution
Please note that this is a sample Simple Expense Tracker Program assignment solved by our Python Programmers. These solutions are intended to be used for research and reference purposes only. If you can learn any concepts by going through the reports and code, then our Python Tutors would be very happy.
- Option 1 - To download the complete solution along with Code, Report and screenshots - Please visit our Python Assignment Sample Solution page
- Option 2 - Reach out to our Python Tutors to get online tutoring related to this assignment and get your doubts cleared
- Option 3 - You can check the partial solution for this assignment in this blog below
Free Assignment Solution - Simple Expense Tracker Program Using Python
import csv
from operation import Operation
# 1 user defined function to load file
def load(csv_file):
count = 0
# dictionary
data = {}
# reading the input file
# try except (else) condition for handling loading error
try:
with open(csv_file, "r") as my_input_file:
# one for loop
for row in csv.reader(my_input_file):
# first row containing column names
# one if statement
if count==0:
for key in row:
# list
data[key] = []
columns = row
# sample values
else:
for val, col in zip(row, columns):
# appending to list
data[col].append(val)
count += 1
except:
print("File doesn't exist!")
return data
# here we are loading the csv_file (sales.csv) and
# storing it in the dictionary "data"
csv_file = 'sales.csv'
data = load(csv_file)
# We are calling the Operation class and providing it with data
# and we are sorting the data based on opType='date'
# you can change opType to "category" or "price"
while True:
opType = input("How do you want to sort the data (enter 'date', 'price' or 'category' without quotes): ")
op = Operation(data, opType=opType)
sortedData = op.sort()
if len(sortedData)==0:
continue
else:
break
print("\nData sorted based on",opType)
print("\nIf you want to see the sorted data just enter 'sortedData' (without quotes) in console")
while True:
by = input("\nHow do you want to group data by (enter 'month', 'year', or 'category' without quotes): ")
cat_grouped = op.groupby(by=by)
if len(cat_grouped)==0:
continue
else:
break
print("\nGrouped Data by", by, "and also printing sum of price for the grouped data\n")
print(cat_grouped)
"""
2 Unit test
1 Sorting function
"""
op = Operation(data, opType='date')
sortedData = op.sort()
assert sortedData["Order Date"][0]=='03/01/2014'
"""2 Categorical function"""
op = Operation(data)
cat_grouped = op.groupby(by='category')
assert sorted(list(cat_grouped.keys()))==['Furniture', 'Office Supplies', 'Technology']
Get the best Python assignment help and tutoring services from our experts now!
About The Author - Alex Johnson
Alex Johnson, a seasoned Python Developer with a robust background in data processing and software engineering, will lead you through this assignment. Alex's expertise lies in creating scalable and maintainable code solutions. In this project, Alex will assist you in writing a Python program to sort transactions by category, month, and year, and sum transaction amounts accordingly.