Skip to content

04-08: Shopping Cart System

Python: Fundamentals

View the live site — ijk37.com

Project 08

Home  |  All Projects  |  Notes  |  Exercises  |  Quiz Hub

A CLI supermarket cart. Browse a product catalogue, add/remove items by ID, apply percentage-off discount codes, and print a formatted receipt with VAT.

Topics covered: lists of dicts · dict lookup · functions · for loop · accumulation · f-string alignment · type conversion · while-loop menu

Difficulty: ⭐⭐ Beginner–Intermediate


How to Run

python main.py

Sample Receipt

══════════════════════════════════════════════════
              RECEIPT
══════════════════════════════════════════════════
  Rice (5 kg)                         ৳   700
  Eggs (dozen)                        ৳   155
  Milk (1 L)                          ৳    90
──────────────────────────────────────────────────
  Subtotal                            ৳   945
  Discount (WELCOME10) -10%           -৳  94.5
  VAT (5%)                            ৳   42.5
──────────────────────────────────────────────────
  TOTAL                               ৳   893.0
══════════════════════════════════════════════════

Key Concepts Practised

Concept Where used
List of dicts CATALOGUE, cart
Dict lookup DISCOUNT_CODES[code]
Searching a list find_product()
list.pop(i) remove_from_cart()
Accumulation cart_total()
Formatted receipt print_receipt()