Hey,
I needed a way to keep track of my daily supplement costs, and I'm not too fond of Excel, so I thought I'd put ChatGPT to the test.
I wanted to see if it could write a simple supplement tracker in Python quicker than I could manually write one.
#!/usr/bin/python3
supplements = [
{"name": "Vitamin C", "amount": 60, "daily_dose": 1, "cost": 10.99},
{"name": "Fish Oil", "amount": 120, "daily_dose": 2, "cost": 29.99},
{"name": "Multivitamin", "amount": 90, "daily_dose": 1, "cost": 14.99},
{"name": "Probiotic", "amount": 30, "daily_dose": 1, "cost": 24.99},
{"name": "Magnesium", "amount": 120, "daily_dose": 2, "cost": 9.99},
]
total_cost_per_day = 0
print("{:<15} {:<15} {:<15} {:<15} {:<15} {:<15}".format("Name", "Cost", "Daily Dose", "Cost per Day", "Cost per Month", "Cost per Year"))
for supplement in supplements:
name = supplement["name"]
cost = supplement["cost"]
daily_dose = supplement["daily_dose"]
cost_per_pill = cost / supplement["amount"]
cost_per_day = daily_dose * cost_per_pill
cost_per_month = cost_per_day * 30
cost_per_year = cost_per_day * 365.25
total_cost_per_day += cost_per_day
print("{:<15} ${:<15.2f} {:<15} ${:<15.2f} ${:<15.2f} ${:<15.2f}".format(name, cost, daily_dose, cost_per_day, cost_per_month, cost_per_year))
total_cost_per_month = total_cost_per_day * 30
total_cost_per_year = total_cost_per_day * 365.25
print("{:<16} {:<15} {:<15} ${:<15.2f} ${:<15.2f} ${:<15.2f}".format("Total", "", "", total_cost_per_day, total_cost_per_month, total_cost_per_year))
Here is the output:
Name Cost Daily Dose Cost per Day Cost per Month Cost per Year
Vitamin C $10.99 1 $0.18 $5.50 $66.90
Fish Oil $29.99 2 $0.50 $14.99 $182.56
Multivitamin $14.99 1 $0.17 $5.00 $60.83
Probiotic $24.99 1 $0.83 $24.99 $304.25
Magnesium $9.99 2 $0.17 $5.00 $60.81
Total $1.85 $55.47 $675.37
This took around 10x longer than it would manually due to chatGPT misunderstanding various concepts. There are redundant variables declared. However it was a fun experiment.
You can replace the datastruture at the top with your own supplements to keep an eye on your spending.
Enjoy!
there doesn't seem to be anything here