Hi buddy, in this article, we are going to make a Python Tip Calculator Project step by step and in the final step, you will gate complete code. If you want only project code then go to the last step and just copy the code and paste your respected python code editor.
Step 1 Create Project Design
Before coding please create a design that is exactly what you want from your python project this very helps when you write code. In this project, we want the below feature our project.
- Welcome message: Welcome To The Amol Blog Tip Calculator
- Input Message: Please Enter Total Bill Amount ₹:-
- Input Massage: How Much % Tips Would You Like To Give (New Line) Please Enter Only Number:-
- Input Massage: How Many People To Spilt The Bill:-
- Final Massage: Each Person Should Pay:- (Correct Amount)
This is what we want.
Step 2 Print Welcome Massage
Here we use the print() function to print a welcome message with the project name.
What is the project name: Amol Blog Tip Calculator.
Then our code is ready.
#Step 2 Print Welcome Massage
print("Welcome To The Amol Blog Tip Calculator")
Step 3 Ask Total Bill Amount and store it in a variable
In this scenario, we use the input() function to allow a user to insert a value.
When the user enters the Amount then we store it as a variable contain.
We want to create a readable variable we use “ bill_amount =” as a variable.
But At the same time, we need to convert the input string to int (round number) that’s why we use the int() function to convert the string to int.
See Below code
#step 3 Ask Total Bill Amount and store it in a variable
bill_amount = int (input ("Please Enter Total Bill Amount ₹:-"))
Step 4 Ask To Tip in % and store it in a variable
Whatever we use in step 3 needs to use the same just need to create a tip percentage new variable to store tip % for calculation here see the below code.
#Step 4 Ask To Tip in % and store it in a variable
tip_percentage = int (input ("How Much % Tips Would You Like To Give \nPlease Enter Only Number:-"))
Step 5 Ask How Many People and store it in a variable
Whatever we use in step 4 needs to use the same just need to create a people new variable to store how many people share bills see the below code.
#Step 5 Ask How Many People and store it in a variable
people = int (input ("How Many People To Spilt The Bill:-"))
Step 6 Do the Final Calculation and Print Divided Amount
- First, calculate the tip amount.
- Then Calculate the tip pulse bill amount.
- Then Calculate the Spit amount.
- using round() Function Round Floating Value to Two Decimals.
- Last using f string print final massage.
See below code
#Step 6 Do the Final Calculation and Print Divided Amount
tip_amount = bill_amount / 100 * tip_percentage
final_bill = bill_amount + tip_amount
spilt_amount = final_bill / people
round_spitlt_amount = round (spilt_amount,2)
print(f"Each Person Should Pay:-{round_spitlt_amount}")
Tip Calculator Final Code
This is our final code you can copy and paste respected your python code editor then just run and enjoy Amol Blog Python Project.
#Step 1 Create Project Design
#Step 2 Print Welcome Massage
print("Welcome To The Amol Blog Tip Calculator")
#step 3 Ask Total Bill Amount and store it in a variable
bill_amount = int (input ("Please Enter Total Bill Amount ₹:-"))
#Step 4 Ask To Tip in % and store it in a variable
tip_percentage = float (input ("How Much % Tips Would You Like To Give \nPlease Enter Only Number:-"))
#Step 5 Ask How Many People and store it in a variable
people = int (input ("How Many People To Spilt The Bill:-"))
#Step 6 Do the Final Calculation and Print Divided Amount
tip_amount = bill_amount / 100 * tip_percentage
final_bill = bill_amount + tip_amount
spilt_amount = final_bill / people
print(f"Each Person Should Pay:-{spilt_amount}")
Thanks for visiting Amol Blog All The Best Your Future.
