Welcome to the Blog !! Today we will learn to build Billing System using Python.
✅ Problem Statement :
Mr. Khan runs a grocery shop. He used to make bills manually. But due to increase in sell, he requires software to generate bills. We are going to help Mr. Khan for developing software.
Following is the list of products and their prices given by Mr. Khan.
Name of Product |
Price (in Rs.) |
Toothpaste |
50 |
Soap |
40 |
Hand wash |
35 |
Rice |
45 |
Oil |
67 |
Wheat |
60 |
Sugar |
77 |
Chocolate |
20 |
Coffee |
80 |
Biscuits |
10 |
✅Concepts Covered in this Post :
- if..else() statement
- for loop
- Dictionary Datatype and its methods
- input () function
- range () function
- sum() function
📚Let's Learn about Dictionary Datatype :
🔹Dictionary is an unordered collection that contains Key:Value Pairs seperated by commas inside curly brackets.
🔹Dictionaries are optimized to retrieve values when the keys is known.
🔹The keys() and values() methods returns a view objects containing keys and values respectively.
📑Let's Code :)
STEP 1 : Create New Python Project
Let's create new python project and Start writing code to develop billing system.
We will take following inputs from user.
- Name of Buyer
- Total number of products you want to buy
- Name and quantity of each product we wanted to buy
Output will be total amount to be paid.
STEP 2 :
Here we are using -
⇒input() function to take input from users.
⇒sum() function is used to perform addition of all the values.
⇒print() function is used to print messages on console.
⇒range() returns numbers between specified start and stop parameters.
● Firstly we will create one dictionary to store products and their prices in key-value pair.
● After this , we will take required inputs from user .
● Based on inputs of products and quantity , we will calculate total amount to be paid .
Refer below sample program :
STEP 3 : Let's run the program and check output :)
Here I'm attaching sample output of the program :
Hope you like this post 😉
You can reach us by entering your details in Contact Us box in the side panel💬
All the Best 👍👍👍👍
Happy Learning 😇😇😇
Source Code By :
Hasti Chopada
(Guest Writer)
Wanted to be our Next Guest Writer ? You are just one DM away 😉 . Reach out to us on our Instagram handle or fill contact us form !