DEV Community

John Mark Rafanan
John Mark Rafanan

Posted on

Day 02 of 100 Days of Code Python Bootcamp by Dr. Angela

For the Day 02, I created a Tip calculator that covers data types, mathematical operations and using f string.

#If the bill was $150.00, split between 5 people, with 12% tip. 
#Each person should pay (150.00 / 5) * 1.12 = 33.6
#Format the result to 2 decimal places = 33.60

print("Welcome to the tip calculator!")
#Get Total bill
total_bill = float(input("What was the total bill? $"))
#Get how many percentage for the bill
tip = int(input("How much tip would you like to give? 10, 12, or 
15? "))
#Get how many persons to split the bill
bill_split_person = int(input("How many people to split the bill? "))

#Get Percentage of tip for total bill and add the value of tip to 
total bill / each person
calc_bill = round((total_bill * float(tip/100) + total_bill) / 
bill_split_person, 2)
final_bill = "{:.2f}".format(calc_bill)
print(f"Each person should pay: ${final_bill}")

Enter fullscreen mode Exit fullscreen mode

Output:

Day 02 Output

Top comments (0)