{"id":4254,"date":"2023-11-09T12:14:55","date_gmt":"2023-11-09T06:44:55","guid":{"rendered":"https:\/\/cbsepython.in\/?p=4254"},"modified":"2025-08-22T20:23:56","modified_gmt":"2025-08-22T14:53:56","slug":"simple-billing-system-in-python-for-class-11","status":"publish","type":"post","link":"https:\/\/cbsepython.in\/simple-billing-system-in-python-for-class-11\/","title":{"rendered":"Simple Billing System in Python for Class 11"},"content":{"rendered":"<h2><span style=\"color: #000000; font-family: 'times new roman', times, serif;\">Python Program to Calculate Shopping Bill with Tax (Simple &amp; Advanced)<\/span><\/h2>\n<p><span style=\"color: #000000; font-family: 'times new roman', times, serif;\">When we go shopping, the bill usually contains two parts \u2013 the actual price of items and the tax applied.<\/span><br \/>\n<span style=\"color: #000000; font-family: 'times new roman', times, serif;\">In this article, we will learn how to create a Python program that calculates:<\/span><\/p>\n<ul>\n<li><span style=\"color: #000000; font-family: 'times new roman', times, serif;\">Bill amount (without tax)<\/span><\/li>\n<li><span style=\"font-family: 'times new roman', times, serif; color: #000000;\">Tax amount (calculated separately)<\/span><\/li>\n<li><span style=\"font-family: 'times new roman', times, serif; color: #000000;\">Final amount (with tax included)<\/span><\/li>\n<\/ul>\n<p><span style=\"color: #000000; font-family: 'times new roman', times, serif;\">We will write two versions of the program:<\/span><\/p>\n<p><span style=\"color: #000000; font-family: 'times new roman', times, serif;\">1. Simple Version (using loops + if-elif-else)<\/span><\/p>\n<p><span style=\"color: #000000; font-family: 'times new roman', times, serif;\">2. Advanced Version (using dictionary)<\/span><\/p>\n<h3><span style=\"color: #000000; font-family: 'times new roman', times, serif;\">Version 1: Simple Python Program using if-elif-else<\/span><\/h3>\n<p><span style=\"color: #000000; font-family: 'times new roman', times, serif;\">This version is written for beginners who know only loops, if, elif, else statements.<\/span><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">#Program: Bill with Different Tax Rate (Simple Version)\r\nprint(\"Available Products:\")\r\nprint(\"1. Pen - 10 Rs (5% tax)\")\r\nprint(\"2. Notebook - 50 Rs (12% tax)\")\r\nprint(\"3. Pencil - 5 Rs (0% tax)\")\r\nprint(\"4. Eraser - 8 Rs (5% tax)\")\r\nprint(\"5. Bag - 700 Rs (18% tax)\")\r\nprint(\"6. Shoes - 1200 Rs (28% tax)\")\r\nprint(\"Enter 0 to finish shopping.\\n\")\r\n\r\nbill_amount = 0\r\ntotal_tax = 0\r\n\r\nprint(\"\\n===== BILL DETAILS =====\")\r\nprint(\"Product\\tQty\\tPrice\\tTotal\\tTax\")\r\n\r\nwhile True:\r\n    choice = int(input(\"Enter product number (0 to stop): \"))\r\n    if choice == 0:\r\n        break\r\n    qty = int(input(\"Enter quantity: \"))\r\n    if choice == 1:\r\n        price, tax_rate, name = 10, 5, \"Pen\"\r\n    elif choice == 2:\r\n        price, tax_rate, name = 50, 12, \"Notebook\"\r\n    elif choice == 3:\r\n        price, tax_rate, name = 5, 0, \"Pencil\"\r\n    elif choice == 4:\r\n        price, tax_rate, name = 8, 5, \"Eraser\"\r\n    elif choice == 5:\r\n        price, tax_rate, name = 700, 18, \"Bag\"\r\n    elif choice == 6:\r\n        price, tax_rate, name = 1200, 28, \"Shoes\"\r\n    else:\r\n        print(\"Invalid choice\")\r\n        continue\r\n\r\n    item_total = price * qty\r\n    item_tax = (item_total * tax_rate) \/ 100\r\n\r\n    bill_amount += item_total\r\n    total_tax += item_tax\r\n\r\n    # Print each purchased item directly\r\n    print(f\"{name:8}\\t{qty}\\t{price}\\t{item_total}\\t{item_tax:.2f}\")\r\n\r\nfinal_amount = bill_amount + total_tax\r\n\r\nprint(\"-----------------------------\")\r\nprint(\"Bill Amount (Without Tax): Rs\", bill_amount)\r\nprint(\"Total Tax: Rs\", round(total_tax, 2))\r\nprint(\"Final Amount (With Tax): Rs\", round(final_amount, 2))\r\nprint(\"=============================\")\r\n<\/pre>\n<p><strong><span style=\"color: #000000; font-family: 'times new roman', times, serif;\">Sample Output:<\/span><\/strong><\/p>\n<pre>Available Products:\r\n1. Pen - 10 Rs (5% tax)\r\n2. Notebook - 50 Rs (12% tax)\r\n3. Pencil - 5 Rs (0% tax)\r\n4. Eraser - 8 Rs (5% tax)\r\n5. Bag - 700 Rs (18% tax)\r\n6. Shoes - 1200 Rs (28% tax)\r\nEnter 0 to finish shopping.\r\n\r\n\r\n===== BILL DETAILS =====\r\nProduct Qty Price Total Tax\r\nEnter product number (0 to stop): 2\r\nEnter quantity: 1\r\nNotebook 1 50 50 6.00\r\nEnter product number (0 to stop): 5\r\nEnter quantity: 2\r\nBag 2 700 1400 252.00\r\nEnter product number (0 to stop): 0\r\n-----------------------------\r\nBill Amount (Without Tax): Rs 1450\r\nTotal Tax: Rs 258.0\r\nFinal Amount (With Tax): Rs 1708.0\r\n=============================<\/pre>\n<h3><span style=\"color: #000000; font-family: 'times new roman', times, serif;\">Version 2: Advanced Python Program using Dictionary<\/span><\/h3>\n<p><span style=\"font-family: 'times new roman', times, serif; color: #000000;\">In this version, we use a dictionary to store product price and tax rate together. This makes the program more flexible and easy to update.<\/span><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\"># Program: Bill with Different Tax Rate (Advanced Version)\r\n\r\n# Dictionary with product : (price, tax_rate%)\r\nproducts = {\r\n    \"Pen\": (10, 5),\r\n    \"Notebook\": (50, 12),\r\n    \"Pencil\": (5, 0),\r\n    \"Eraser\": (8, 5),\r\n    \"Bag\": (700, 18),\r\n    \"Shoes\": (1200, 28)\r\n}\r\n\r\ncart = {}\r\n\r\nprint(\"Available Products (Price, Tax Rate):\")\r\nfor item, (price, tax) in products.items():\r\n    print(f\"{item} - Rs{price} (Tax {tax}%)\")\r\n\r\nprint(\"\\nEnter 'done' when finished.\\n\")\r\n\r\nwhile True:\r\n    product = input(\"Enter product name: \").capitalize()\r\n    if product.lower() == \"done\":\r\n        break\r\n    elif product in products:\r\n        qty = int(input(f\"Enter quantity of {product}: \"))\r\n        cart[product] = cart.get(product, 0) + qty\r\n    else:\r\n        print(\"Product not available. Please choose from the list.\")\r\n\r\nbill_amount = 0\r\ntotal_tax = 0\r\n\r\nprint(\"\\n===== BILL SUMMARY =====\")\r\nfor item, qty in cart.items():\r\n    price, tax_rate = products[item]\r\n    item_total = price * qty\r\n    item_tax = (item_total * tax_rate) \/ 100\r\n    bill_amount += item_total\r\n    total_tax += item_tax\r\n    print(f\"{item} (x{qty}) = Rs {item_total} | Tax @{tax_rate}% = Rs {item_tax:.2f}\")\r\n\r\nfinal_amount = bill_amount + total_tax\r\n\r\nprint(\"-------------------------\")\r\nprint(f\"Bill Amount (Without Tax): Rs {bill_amount}\")\r\nprint(f\"Total Tax: Rs {total_tax:.2f}\")\r\nprint(f\"Final Amount (With Tax): Rs {final_amount:.2f}\")\r\nprint(\"=========================\")\r\n<\/pre>\n<p><strong><span style=\"color: #000000; font-family: 'times new roman', times, serif;\">Sample Output:<\/span><\/strong><\/p>\n<pre>Available Products (Price, Tax Rate):\r\nPen - Rs10 (Tax 5%)\r\nNotebook - Rs50 (Tax 12%)\r\nPencil - Rs5 (Tax 0%)\r\nEraser - Rs8 (Tax 5%)\r\nBag - Rs700 (Tax 18%)\r\nShoes - Rs1200 (Tax 28%)\r\n\r\nEnter 'done' when finished.\r\n\r\nEnter product name: pen \r\nProduct not available. Please choose from the list.\r\nEnter product name: Pen\r\nEnter quantity of Pen: 2\r\nEnter product name: Notebook\r\nEnter quantity of Notebook: 3\r\nEnter product name: \r\nProduct not available. Please choose from the list.\r\nEnter product name: Bag\r\nEnter quantity of Bag: 3\r\nEnter product name: done\r\n\r\n===== BILL SUMMARY =====\r\nPen (x2) = Rs 20 | Tax @5% = Rs 1.00\r\nNotebook (x3) = Rs 150 | Tax @12% = Rs 18.00\r\nBag (x3) = Rs 2100 | Tax @18% = Rs 378.00\r\n-------------------------\r\nBill Amount (Without Tax): Rs 2270\r\nTotal Tax: Rs 397.00\r\nFinal Amount (With Tax): Rs 2667.00\r\n=========================<\/pre>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #000000; font-family: 'times new roman', times, serif;\">This version is suitable for Class 12 and project work, as it uses dictionary and is more professional. <\/span><span style=\"color: #000000; font-family: 'times new roman', times, serif;\">If you are just starting with Python and learning loops, if-elif-else, then go with Version 1 (Simple). <\/span><span style=\"color: #000000; font-family: 'times new roman', times, serif;\">If you are comfortable with dictionaries and lists, then try Version 2 (Advanced).<\/span><span style=\"color: #000000; font-family: 'times new roman', times, serif;\">Both programs clearly show bill amount, tax amount, and final amount separately.<\/span><\/p>\n<h2><span style=\"color: #000000;\">Simple Billing System in Python<\/span><\/h2>\n<p><span style=\"color: #000000;\">Here a simple billing software written in Python. It allows you to create invoices for customers, calculate discounts based on the payment method, and include additional costs for a carry bag. Here&#8217;s an explanation of the program for class 11 students:<\/span><\/p>\n<ol>\n<li><span style=\"color: #000000;\">The program starts with an infinite loop using <strong>while True:<\/strong>. This loop continues running until the user decides to exit by pressing &#8216;0&#8217;.<\/span><\/li>\n<li><span style=\"color: #000000;\">It greets the user and displays a menu of payment methods: Cash, UPI, and Card.<\/span><\/li>\n<li><span style=\"color: #000000;\">It prompts the user to enter the name and address of the customer.<\/span><\/li>\n<li><span style=\"color: #000000;\">The user is asked to select the payment method by entering a number (1 for Cash, 2 for UPI, 3 for Card).<\/span><\/li>\n<li><span style=\"color: #000000;\">The program then asks for the number of items the customer has purchased.<\/span><\/li>\n<li><span style=\"color: #000000;\">It creates an empty list called <strong>items<\/strong> to store item names and prices and initializes a <strong>total_price<\/strong> variable to keep track of the total cost.<\/span><\/li>\n<li><span style=\"color: #000000;\">Inside a for loop, the program asks the user for the name and price of each item and adds them to the <strong>items<\/strong> It also updates the <strong>total_price<\/strong> with the cost of each item.<\/span><\/li>\n<li><span style=\"color: #000000;\">Depending on the chosen payment method, the program calculates a discount: 5% for Cash, 10% for UPI, and 7% for Card.<\/span><\/li>\n<li><span style=\"color: #000000;\">The program asks if the customer wants a carry bag and, if so, charges an additional Rs. 10 for it.<\/span><\/li>\n<li><span style=\"color: #000000;\">It calculates the GST (Goods and Services Tax) at a rate of 18% on the total price after the discount.<\/span><\/li>\n<li><span style=\"color: #000000;\">It calculates the final total price with GST, including the discount and carry bag cost.<\/span><\/li>\n<li><span style=\"color: #000000;\">The program then displays an invoice with the customer&#8217;s name, address, payment method, discount, list of items and their prices, total price without GST, GST, carry bag cost, and the total price with GST.<\/span><\/li>\n<li><span style=\"color: #000000;\">After displaying the invoice, it asks the user if they want to enter another entry or exit the program. If the user enters &#8216;0&#8217;, the loop will exit, and the program will terminate.<\/span><\/li>\n<\/ol>\n<p><span style=\"color: #000000;\">This program helps store owners or cashiers to quickly generate invoices for customers and calculate the total cost based on the payment method, while also offering discounts for certain payment methods and charging for optional items like a carry bag. It&#8217;s a basic example of a billing system and can be expanded or improved for real-world applications.<\/span><\/p>\n<p>&nbsp;<\/p>\n<h3><span style=\"color: #000000;\">Source Code:<\/span><\/h3>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">while True:\r\n    print(\"Welcome to billing software!\")\r\n    print(\"Payment methods\")\r\n    print(\"1: Cash\")\r\n    print(\"2: UPI\")\r\n    print(\"3: Card\")\r\n\r\n    name = input('Enter the name of the customer: ')\r\n    address = input('Enter the address of the customer: ')\r\n    payment = int(input('Enter the mode of payment (1 for Cash, 2 for UPI, 3 for Card): '))\r\n    num_items = int(input(\"Enter how many items the customer has taken: \"))\r\n\r\n    items = []  # List to store item names and prices\r\n    total_price = 0\r\n\r\n    for i in range(num_items):\r\n        item_name = input(\"Enter the name of the item: \")\r\n        item_price = float(input(\"Price of the item: \"))\r\n        items.append((item_name, item_price))  # Store item name and price in a tuple\r\n        total_price += item_price\r\n\r\n    discount = 0  # Initialize discount with a default value\r\n\r\n    if payment == 1:  # Cash\r\n        discount = 0.05*total_price #for 5% discount\r\n    elif payment == 2:  # UPI\r\n        discount = 0.10* total_price #for 10% discount\r\n    elif payment == 3:  # Card\r\n        discount = 0.07* total_price #for 7% discount\r\n\r\n    \r\n    carry_bag = input(\"Does the customer want a carry bag? (Type 'y' for yes, 'n' for no): \")\r\n    carry_bag_cost = 0\r\n    if carry_bag == \"y\":\r\n        carry_bag_cost = 10\r\n    GST = 0.18*(total_price-discount)\r\n    total_price_with_GST = ((total_price - discount) + GST + carry_bag_cost)\r\n\r\n    print(\"---------------------------------------------------------------Invoice-------------------------------------------------------------------\")\r\n    print(\"Name of the customer is:\", name)\r\n    print(\"Address of the customer is:\", address)\r\n\r\n    if payment == 1:\r\n        print(\"Mode of payment: Cash\")\r\n        print(\"You got a 5% discount\")\r\n    elif payment == 2:\r\n        print(\"Mode of payment: UPI\")\r\n        print(\"You got a 10% discount\")\r\n    elif payment == 3:\r\n        print(\"Mode of payment: Card\")\r\n        print(\"You got a 7% discount\")\r\n\r\n    print(\"Discount is Rs.\", discount)\r\n    print(\"Items purchased:\")\r\n    for item in items:\r\n        print(\"Item:\", item[0])\r\n        print(\"Price:\", item[1])\r\n\r\n    print(\"Total without GST is Rs.\", total_price - discount)\r\n    print(\"GST is Rs.\", GST)\r\n    print(\"Carry Bag cost is Rs.\", carry_bag_cost)\r\n    print(\"Total price with GST is Rs.\", total_price_with_GST)\r\n\r\n    user_input = input(\"Press Enter key to enter another entry or '0' to exit: \")\r\n    if user_input == \"0\":\r\n        break\r\n<\/pre>\n<h3><span style=\"color: #000000;\">Output:<\/span><\/h3>\n<p>&nbsp;<\/p>\n<pre><span style=\"color: #000000;\">Welcome to billing software!<\/span>\r\n<span style=\"color: #000000;\">Payment methods<\/span>\r\n<span style=\"color: #000000;\">1: Cash<\/span>\r\n<span style=\"color: #000000;\">2: UPI<\/span>\r\n<span style=\"color: #000000;\">3: Card<\/span>\r\n<span style=\"color: #000000;\">Enter the name of the customer: \"Harshit\"<\/span>\r\n<span style=\"color: #000000;\">Enter the address of the customer: \"Ashok Nagar, Delhi\"<\/span>\r\n<span style=\"color: #000000;\">Enter the mode of payment (1 for Cash, 2 for UPI, 3 for Card): 2<\/span>\r\n<span style=\"color: #000000;\">Enter how many items the customer has taken: 5<\/span>\r\n<span style=\"color: #000000;\">Enter the name of the item: \"Pen\"<\/span>\r\n<span style=\"color: #000000;\">Price of the item: 10<\/span>\r\n<span style=\"color: #000000;\">Enter the name of the item: \"Book\"<\/span>\r\n<span style=\"color: #000000;\">Price of the item: 420<\/span>\r\n<span style=\"color: #000000;\">Enter the name of the item: \"Marker\"<\/span>\r\n<span style=\"color: #000000;\">Price of the item: 35<\/span>\r\n<span style=\"color: #000000;\">Enter the name of the item: \"Chart Papers\"<\/span>\r\n<span style=\"color: #000000;\">Price of the item: 50<\/span>\r\n<span style=\"color: #000000;\">Enter the name of the item: \"Stapler\"<\/span>\r\n<span style=\"color: #000000;\">Price of the item: 55<\/span>\r\n<span style=\"color: #000000;\">Does the customer want a carry bag? (Type 'y' for yes, 'n' for no): \"y\"<\/span>\r\n<span style=\"color: #000000;\">------------------------Invoice------------------------------------------<\/span>\r\n<span style=\"color: #000000;\">('Name of the customer is:', 'Harshit')<\/span>\r\n<span style=\"color: #000000;\">('Address of the customer is:', 'Ashok Nagar, Delhi')<\/span>\r\n<span style=\"color: #000000;\">Mode of payment: UPI<\/span>\r\n<span style=\"color: #000000;\">You got a 10% discount<\/span>\r\n<span style=\"color: #000000;\">('Discount is Rs.', 57.0)<\/span>\r\n<span style=\"color: #000000;\">Items purchased:<\/span>\r\n<span style=\"color: #000000;\">('Item:', 'Pen')<\/span>\r\n<span style=\"color: #000000;\">('Price:', 10.0)<\/span>\r\n<span style=\"color: #000000;\">('Item:', 'Book')<\/span>\r\n<span style=\"color: #000000;\">('Price:', 420.0)<\/span>\r\n<span style=\"color: #000000;\">('Item:', 'Marker')<\/span>\r\n<span style=\"color: #000000;\">('Price:', 35.0)<\/span>\r\n<span style=\"color: #000000;\">('Item:', 'Chart Papers')<\/span>\r\n<span style=\"color: #000000;\">('Price:', 50.0)<\/span>\r\n<span style=\"color: #000000;\">('Item:', 'Stapler')<\/span>\r\n<span style=\"color: #000000;\">('Price:', 55.0)<\/span>\r\n<span style=\"color: #000000;\">('Total without GST is Rs.', 513.0)<\/span>\r\n<span style=\"color: #000000;\">('GST is Rs.', 92.34)<\/span>\r\n<span style=\"color: #000000;\">('Carry Bag cost is Rs.', 10)<\/span>\r\n<span style=\"color: #000000;\">('Total price with GST is Rs.', 615.34)<\/span>\r\n<span style=\"color: #000000;\">Press Enter key to enter another entry or '0' to exit: <\/span><\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Python Program to Calculate Shopping Bill with Tax (Simple &amp; Advanced) When we go shopping, the bill usually contains two parts \u2013 the actual price of items and the tax applied. In this article, we will learn how to create a Python program that calculates: Bill amount (without tax) Tax amount (calculated separately) Final amount [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15,20,43],"tags":[],"class_list":["post-4254","post","type-post","status-publish","format-standard","hentry","category-cbse-sample-papers-class-11","category-cbse-computer-science-with-python-class-12","category-python-projects"],"_links":{"self":[{"href":"https:\/\/cbsepython.in\/wp-json\/wp\/v2\/posts\/4254","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cbsepython.in\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cbsepython.in\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cbsepython.in\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/cbsepython.in\/wp-json\/wp\/v2\/comments?post=4254"}],"version-history":[{"count":4,"href":"https:\/\/cbsepython.in\/wp-json\/wp\/v2\/posts\/4254\/revisions"}],"predecessor-version":[{"id":5522,"href":"https:\/\/cbsepython.in\/wp-json\/wp\/v2\/posts\/4254\/revisions\/5522"}],"wp:attachment":[{"href":"https:\/\/cbsepython.in\/wp-json\/wp\/v2\/media?parent=4254"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cbsepython.in\/wp-json\/wp\/v2\/categories?post=4254"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cbsepython.in\/wp-json\/wp\/v2\/tags?post=4254"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}