DEV Community

loading...
Cover image for My #100daysOfCode Challenge - Python 100 projects in 100 days - Journal Entries - Day 2

My #100daysOfCode Challenge - Python 100 projects in 100 days - Journal Entries - Day 2

abeck617 profile image Anthony Beckford🚀 ・1 min read

Day two - Tip Calculator

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: You might need to do some research in Google to figure out how to do this.

print("Welcome to the tip Calculator.")

bill = float(input("What is the total bill? $"))

tip = int(input("What percentage tip would you like to give? 10, 12, or 15? "))

people = int(input("How many people to split the bill? "))

payment_per_person = round(float((bill / people ) * (tip / 100 + 1)), 2)

print(f"Each person should pay: ${payment_per_person}")

Output:
Welcome to the tip Calculator.
What is the total bill? $100
What percentage tip would you like to give? 10, 12, or 15? 10
How many people to split the bill? 5
Each person should pay: $22.0

Key Takeaways:

  1. Learned about Data types
  2. Numbers
  3. Operations
  4. Type Conversion
  5. f-Strings

Discussion (0)

pic
Editor guide