Skip to content

Welcome to the **Grocery Store Billing System** ๐ŸŽ‰ This is a beginner-friendly Python project that simulates a **supermarket billing system**. It allows customers to **view stock, buy items, manage quantities, and generate a final bill** ๐Ÿงพ.

Notifications You must be signed in to change notification settings

piyushkadam96k/Grocery-Store-Billing-System-Python-

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

4 Commits
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ›’ Grocery Billing System (Python)

๐Ÿ“˜ Overview

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.


๐Ÿง  Features

โœ… 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


๐Ÿงฉ Code

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()

โš™๏ธ How to Run

  1. Save the file as billing.py
  2. Open a terminal and run:
    python billing.py
  3. Follow on-screen prompts to:
    • Select grocery items
    • Enter quantity
    • Quit (q) to see your total bill

๐Ÿงพ Example Output

===== 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! ๐Ÿ›’

๐Ÿ’ก Future Enhancements

  • Add item removal/editing
  • Save bills to a text or CSV file
  • Add GST/taxes and discounts
  • GUI version using Tkinter or PyQt

About

Welcome to the **Grocery Store Billing System** ๐ŸŽ‰ This is a beginner-friendly Python project that simulates a **supermarket billing system**. It allows customers to **view stock, buy items, manage quantities, and generate a final bill** ๐Ÿงพ.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages