DEV Community

Cover image for My #100daysOfCode Challenge - Python 100 projects in 100 days - Journal Entries - Day 2
Anthony Beckford🚀
Anthony Beckford🚀

Posted on

1 1

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

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

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay