This is a simple Python-based Grocery Billing System that allows users to:
- View available grocery items with prices ๐งพ
- Select items to purchase by number ๐ข
- Enter quantity for each item ๐งฎ
- Get a final bill showing all items, quantities, and total cost ๐ฐ
A great beginner-friendly Python project to understand loops, dictionaries, user input, and basic logic.
โ
Display available stock with item prices
โ
Add multiple items and quantities to your cart
โ
Automatic calculation of total cost
โ
Simple text-based interface for easy use
โ
Dynamic dictionary-based product management
groceries = {
"bananas": 87,
"bread": 219,
"milk": 113,
"eggs": 351,
"cheese": 396,
"chicken": 528,
"rice": 193,
"pasta": 157,
"tomatoes": 202,
"apple": 100
}
def billing():
print("\n===== Welcome to XYZ store =====\n")
print("\t==== Stock is here ====")
items = list(groceries.keys())
cart = {} # to store what user buys
for i, key in enumerate(items, start=1):
print(f"\t {i}. {key} : {groceries[key]}")
while True:
user = int(input(f"\nWhich item do you want to buy (enter number): "))
if 1 <= user <= len(items):
chosen_item = items[user - 1]
price = groceries[chosen_item]
qty = int(input(f"Enter quantity of {chosen_item}: "))
# add to cart
if chosen_item in cart:
cart[chosen_item] += qty
else:
cart[chosen_item] = qty
print(f"\nโ Added {qty} {chosen_item}(s) - {price*qty} total")
else:
print("\nโ Invalid choice, please try again.")
choice = input("\nDo you want to quit? (press 'q' to quit, Enter to continue): ")
if choice.lower() == 'q':
print("\n===== Final Bill =====")
total = 0
for item, qty in cart.items():
price = groceries[item]
cost = price * qty
total += cost
print(f"{item} x {qty} = {cost}")
print("----------------------")
print(f"Grand Total = {total}")
print("Thank you for shopping with us! ๐")
break
billing()- Save the file as
billing.py - Open a terminal and run:
python billing.py
- Follow on-screen prompts to:
- Select grocery items
- Enter quantity
- Quit (
q) to see your total bill
===== Welcome to XYZ store =====
==== Stock is here ====
1. bananas : 87
2. bread : 219
3. milk : 113
...
Which item do you want to buy (enter number): 2
Enter quantity of bread: 3
โ Added 3 bread(s) - 657 total
Do you want to quit? (press 'q' to quit, Enter to continue): q
===== Final Bill =====
bread x 3 = 657
----------------------
Grand Total = 657
Thank you for shopping with us! ๐
- Add item removal/editing
- Save bills to a text or CSV file
- Add GST/taxes and discounts
- GUI version using Tkinter or PyQt