Day 001 of the 100 Days of Python challenge builds a command-line tip calculator. The program collects a bill total, a tip percentage, and the number of people sharing the bill, then calculates each person’s portion.

Where Day 000 focused on collecting text and combining it into a sentence, Day 001 shifts to working with numbers — a small but important jump for beginners, since Python treats numeric input differently from plain text. This project introduces type conversion, basic math operations, and formatted currency output, all wrapped in a practical, real-world calculator you could actually use the next time you’re splitting a restaurant bill.

This guide walks through the full Day 001 source code, explains exactly how the tip calculation works, and shows how to run the project yourself.

Project Overview

The program asks for three values:

  1. The total bill
  2. The tip percentage
  3. The number of people splitting the bill

It converts the bill to a float and the other values to int values. The tip is calculated as a percentage of the subtotal, added to the bill, and divided by the number of people.

Welcome to the tip calculator!
What was the total bill?
$120
How much tip would you like to give? $10, $12, or $15?
15
How many people to split the bill?
4
Each person should pay: $34.50

Source Code

The Day 001 project is contained in day001/main.py in the 100daysofpython repository:

def main():
    print("Welcome to the tip calculator!")

    sub_total = float(input("What was the total bill?\n$"))
    tip = int(input("How much tip would you like to give? $10, $12, or $15?\n"))
    people = int(input("How many people to split the bill?\n"))

    tip_amount = sub_total * (tip / 100)
    total_bill = sub_total + tip_amount
    pay_per_person = total_bill / people

    final_amount = f"{pay_per_person:.2f}"
    print(f"Each person should pay: ${final_amount}")


if __name__ == "__main__":
    main()

How the Program Works

Collect and Convert Numeric Input

input() always returns a string, even when the user types numbers. Wrapping the call in float() or int() converts that text into a usable number:

sub_total = float(input("What was the total bill?\n$"))
tip = int(input("How much tip would you like to give? $10, $12, or $15?\n"))
people = int(input("How many people to split the bill?\n"))

sub_total uses float() because a bill can include cents, while tip and people use int() since a whole-number percentage and a whole-number headcount are enough for this project.

Calculate the Tip and Total

The calculation is separated into clear, readable steps:

tip_amount = sub_total * (tip / 100)
total_bill = sub_total + tip_amount
pay_per_person = total_bill / people

tip / 100 converts a whole-number percentage like 15 into a decimal like 0.15, which is then multiplied against the subtotal to find the tip amount in dollars.

Format the Output

final_amount = f"{pay_per_person:.2f}"
print(f"Each person should pay: ${final_amount}")

The :.2f format specifier rounds a number to exactly two decimal places, which is essential for displaying currency correctly — without it, Python might print something like 34.5 or 34.499999999999996 instead of a clean 34.50.

Run the Main Function

The script wraps its work in main() and uses the main-module guard so the function runs only when the file is executed directly:

if __name__ == "__main__":
    main()

What This Project Teaches

Day 001 provides practice with:

  • Converting string input into float and int values
  • Choosing the right numeric type for each piece of data
  • Performing percentage calculations
  • Formatting numbers as currency with f-strings and :.2f
  • Structuring a script with main() and the main-module guard

It also shows why choosing the right type matters: the bill requires decimal support, while a tip percentage and people count can be whole numbers.

Running the Project

git clone https://github.com/victorhugo81/100daysofpython.git
cd 100daysofpython/day001
python main.py

If you are new to Python environments, see Python Virtual Environments: Setup Guide & Best Practices.

Possible Next Steps

Once you understand the existing code, try extending it:

  • Validate that the tip entered is a reasonable percentage, instead of accepting any number
  • Round pay_per_person up to the nearest cent so the group never comes up short
  • Let the user choose a custom tip percentage instead of picking from the suggested options
  • Add a summary line showing the total bill including tip, not just each person’s share

Common Beginner Mistakes

A few pitfalls to watch for when adapting this project:

  • Forgetting to convert input at all. If you skip float() or int(), Python treats every answer as a string, and sub_total + tip_amount would raise a TypeError instead of doing math.
  • Using int() where float() is needed. If you accidentally use int() on the bill amount, any cents typed in would be silently dropped instead of rounded.
  • Skipping the :.2f format. Floating-point math can produce results like 34.499999999999996 due to how computers store decimals — formatting to two decimal places hides that imprecision for a clean, correct-looking price.

Conclusion

Day 001 of the 100 Days of Python challenge moves from text-based input to numeric calculations, showing how float() and int() convert user input into usable numbers, and how f-string formatting turns a raw calculation into clean, readable currency output.

View the Day 001 source code on GitHub, then continue through the repository’s project index as you build more Python programs, one day and one small project at a time.