Simple Billing System in Python

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’s an explanation of the program for class 11 students:

  1. The program starts with an infinite loop using while True:. This loop continues running until the user decides to exit by pressing ‘0’.
  2. It greets the user and displays a menu of payment methods: Cash, UPI, and Card.
  3. It prompts the user to enter the name and address of the customer.
  4. The user is asked to select the payment method by entering a number (1 for Cash, 2 for UPI, 3 for Card).
  5. The program then asks for the number of items the customer has purchased.
  6. It creates an empty list called items to store item names and prices and initializes a total_price variable to keep track of the total cost.
  7. Inside a for loop, the program asks the user for the name and price of each item and adds them to the items It also updates the total_price with the cost of each item.
  8. Depending on the chosen payment method, the program calculates a discount: 5% for Cash, 10% for UPI, and 7% for Card.
  9. The program asks if the customer wants a carry bag and, if so, charges an additional Rs. 10 for it.
  10. It calculates the GST (Goods and Services Tax) at a rate of 18% on the total price after the discount.
  11. It calculates the final total price with GST, including the discount and carry bag cost.
  12. The program then displays an invoice with the customer’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.
  13. After displaying the invoice, it asks the user if they want to enter another entry or exit the program. If the user enters ‘0’, the loop will exit, and the program will terminate.

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’s a basic example of a billing system and can be expanded or improved for real-world applications.

 

Source Code:

while True:
    print("Welcome to billing software!")
    print("Payment methods")
    print("1: Cash")
    print("2: UPI")
    print("3: Card")

    name = input('Enter the name of the customer: ')
    address = input('Enter the address of the customer: ')
    payment = int(input('Enter the mode of payment (1 for Cash, 2 for UPI, 3 for Card): '))
    num_items = int(input("Enter how many items the customer has taken: "))

    items = []  # List to store item names and prices
    total_price = 0

    for i in range(num_items):
        item_name = input("Enter the name of the item: ")
        item_price = float(input("Price of the item: "))
        items.append((item_name, item_price))  # Store item name and price in a tuple
        total_price += item_price

    discount = 0  # Initialize discount with a default value

    if payment == 1:  # Cash
        discount = 0.05*total_price #for 5% discount
    elif payment == 2:  # UPI
        discount = 0.10* total_price #for 10% discount
    elif payment == 3:  # Card
        discount = 0.07* total_price #for 7% discount

    
    carry_bag = input("Does the customer want a carry bag? (Type 'y' for yes, 'n' for no): ")
    carry_bag_cost = 0
    if carry_bag == "y":
        carry_bag_cost = 10
    GST = 0.18*(total_price-discount)
    total_price_with_GST = ((total_price - discount) + GST + carry_bag_cost)

    print("---------------------------------------------------------------Invoice-------------------------------------------------------------------")
    print("Name of the customer is:", name)
    print("Address of the customer is:", address)

    if payment == 1:
        print("Mode of payment: Cash")
        print("You got a 5% discount")
    elif payment == 2:
        print("Mode of payment: UPI")
        print("You got a 10% discount")
    elif payment == 3:
        print("Mode of payment: Card")
        print("You got a 7% discount")

    print("Discount is Rs.", discount)
    print("Items purchased:")
    for item in items:
        print("Item:", item[0])
        print("Price:", item[1])

    print("Total without GST is Rs.", total_price - discount)
    print("GST is Rs.", GST)
    print("Carry Bag cost is Rs.", carry_bag_cost)
    print("Total price with GST is Rs.", total_price_with_GST)

    user_input = input("Press Enter key to enter another entry or '0' to exit: ")
    if user_input == "0":
        break

 

 

 

Output:

 

Welcome to billing software!
Payment methods
1: Cash
2: UPI
3: Card
Enter the name of the customer: "Harshit"
Enter the address of the customer: "Ashok Nagar, Delhi"
Enter the mode of payment (1 for Cash, 2 for UPI, 3 for Card): 2
Enter how many items the customer has taken: 5
Enter the name of the item: "Pen"
Price of the item: 10
Enter the name of the item: "Book"
Price of the item: 420
Enter the name of the item: "Marker"
Price of the item: 35
Enter the name of the item: "Chart Papers"
Price of the item: 50
Enter the name of the item: "Stapler"
Price of the item: 55
Does the customer want a carry bag? (Type 'y' for yes, 'n' for no): "y"
------------------------Invoice------------------------------------------
('Name of the customer is:', 'Harshit')
('Address of the customer is:', 'Ashok Nagar, Delhi')
Mode of payment: UPI
You got a 10% discount
('Discount is Rs.', 57.0)
Items purchased:
('Item:', 'Pen')
('Price:', 10.0)
('Item:', 'Book')
('Price:', 420.0)
('Item:', 'Marker')
('Price:', 35.0)
('Item:', 'Chart Papers')
('Price:', 50.0)
('Item:', 'Stapler')
('Price:', 55.0)
('Total without GST is Rs.', 513.0)
('GST is Rs.', 92.34)
('Carry Bag cost is Rs.', 10)
('Total price with GST is Rs.', 615.34)
Press Enter key to enter another entry or '0' to exit: 

 

Screenshots: 

Simple Billing System in Python

Simple Billing System in Python for Class 11

 

 

 

 

 

 

By cbsepython

A complete solution for the students of class 9 to 12 having subject Information Technology (402), Computer Science (083). Explore our website for all the useful content as Topic wise notes, Solved QNA, MCQs, Projects and Quiz related to the latest syllabus.

Copywrite © 2020-2024, CBSE Python,
All Rights Reserved