Created a tip calculator!
Focused on: - Data types - Operations - Casting - f Strings
This commit is contained in:
parent
52c595a0c9
commit
31f4206fbf
1 changed files with 13 additions and 0 deletions
13
Day 2/tip-calculator
Normal file
13
Day 2/tip-calculator
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
#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
|
||||
#Tip: There are 2 ways to round a number. You might have to do some Googling to solve this.💪
|
||||
#HINT 1: https://www.google.com/search?q=how+to+round+number+to+2+decimal+places+python&oq=how+to+round+number+to+2+decimal
|
||||
#HINT 2: https://www.kite.com/python/answers/how-to-limit-a-float-to-two-decimal-places-in-python
|
||||
print("Welcome to the tip calculator!")
|
||||
total_bill = float(input("What was the total bill? $"))
|
||||
percent_tip = int(input("What percentage tip would you like to give? 10, 12, or 15? "))
|
||||
total_people = int(input("How many people to split the bill? "))
|
||||
bill_with_tip = total_bill + (total_bill * (percent_tip / 100))
|
||||
cost_per_person = round(bill_with_tip / total_people, 2)
|
||||
print(f"Each person should pay: ${cost_per_person}")
|
||||
Loading…
Add table
Add a link
Reference in a new issue