Sweet Store
Sweet Store
Sweet Store
This Python code provides a simplified system for managing a sweet store,
with features for purchasing sweets and an admin mode for viewing profits
and updating sweet prices. Utilizing the popular libraries matplotlib, pandas,
and numpy, this program offers users the ability to buy sweets, view profits,
and make necessary adjustments to sweet prices. The sweet store's
inventory and sales data are stored in a CSV file, ensuring seamless data
management and persistence. The program initiates with a welcoming
message, presenting users with a menu to select their desired action.
Dataset:-
The project uses a dataset stored in a CSV file named
"C:/Users/LENOVO/Downloads/sweet store.xlsx - Sheet1.csv".This dataset
contains information about the sweets available in the store, including
the name of the sweet, its price per kilogram, and the profit generated
from its sales. The "Profit" column likely gets updated dynamically as
customers make purchases. The code accesses and modifies this
dataset using the pandas library, allowing for the management of
inventory, prices, and profits.
CSV FILE:-
CSV FILE NOTEPAD VIEW:
Code structure:
The provided code follows a structured approach that can be defined as
follows:
This organized structure ensures that the code performs its intended
functions while maintaining readability and ease of maintenance.
Code :
import matplotlib.pyplot as plt
import pandas
import numpy
df = pandas.read_csv( )
print("***WELCOME TO CHHAPPAN BHOG ***")
def choice():
print("""Enter your choice:
1. Buy sweet
2. Admin mode
3. Exit""")
sweet_name = []
price = []
w = 0
while w == 0:
choice()
i = int(input(""))
if i == 1:
a = {}
p = 0
q= 0
while q == 0 :
for b in range(len(price)):
print(b, ".", sweet_name[b], "------>
Rs.", price[b], "per Kg")
df.iloc[k, 3] = df.iloc[k, 3] +
calculate(k, g)
if k == 121:
print("Your bill:-")
for c in a:
print(c, " ", a[c])
print("Your total price is:-", p)
print("***Thank you for shopping***")
w += 1
q += 1
df.to_csv("C:/Users/LENOVO/Downloads/sweet store.xlsx -
Sheet1.csv", index_col=0)
elif i == 2:
print("""Enter your choice:-
1. View profit
2. Change price of sweet
""")
f = int(input(" "))
if f == 1:
profit = df['profit']
x = numpy.arange(len(profit))
plt.bar(x, profit)
plt.xticks(x, df.sweet_name)
plt.xlabel("Sweet Name")
plt.ylabel("Profit")
plt.title("Store profit")
plt.show()
w+=1
else:
print("******SWEET SHOP MENU******")
for b in range(len(price)):
print(b, ".", sweet_name[b], "------>
Rs.", price[b], "per Kg")
y = int(input("Enter your choice:-"))
u = int(input("Enter the new price per
kg:-"))
df.iloc[y, 2] = u
print("Successful updated:-\n")
print(df.iloc[:, [1, 2]])
df.to_csv("C:/Users/LENOVO/Downloads/sweet
store.xlsx - Sheet1.csv", index=False )
w+=1
elif i == 3:
print("Exit")
w += 1
break
else:
print("Enter a valid option")
w+=1
Output:
(For option 1)
(For option 2)
(For option 2 if we go to admin mode)
(For option 3)
Conclusion:
The provided Python script presents a simple yet effective system for
managing a sweet store, combining functionalities for both customers and
administrators. The code enables users to interact with the store, facilitating
the purchase of various sweets and providing an admin mode for
overseeing profits and adjusting sweet prices as needed. Leveraging
libraries such as matplotlib, pandas, and numpy, the program ensures
seamless data handling and visualization, while the utilization of a CSV file
allows for the persistent storage and management of the store's inventory
and sales data. By encapsulating different functionalities within well-defined
functions and employing a structured approach, the code ensures clarity
and ease of modification, making it a practical and scalable solution for
sweet store management.This code can be further expanded or customized
to meet specific requirements and explore additional features.