What you'll build
After a study-group hangout, ask for the total bill and the number of people. Divide. Print a clean three-line receipt. Practice mixing int() and float() with division.
Requirements
The must-do parts. If any are missing, we'll ask you to take another pass.
- Ask the user for the total bill in GHS (a decimal is allowed) and the number of people sharing it.
- Convert the bill with
float()and the people count withint(). - Calculate how much each person pays.
- Print three labelled lines: the bill, the number of people, and the per-person amount.
Bonus, if you're feeling brave
- Ask if the group wants to add a 10% tip and include it before splitting.
- Round the per-person amount to two decimal places with
round(..., 2).
Examples
What your program should look like when it runs. Lines starting with $ are typed by you; the rest is your program.
Example cell run
Total bill (GHS): 240
Number of people: 4
Bill: GHS 240.0
People: 4
Each person pays: GHS 60.0Where to start
Copy this scaffold into a new file. You don't have to use it — it's just a friendly nudge.
# Study-group bill split
bill_text = input("Total bill (GHS): ")
people_text = input("Number of people: ")
# TODO: convert bill_text to float and people_text to int
# TODO: calculate how much each person pays
# TODO: print three labelled linesHow we'll grade it
Four checks, four points. Three or above is passing — we'll ask you to revise anything we can't tick.
| Check | What we look for | Pt |
|---|---|---|
| It runs | Asks both questions, prints three labelled lines without errors. | 1 |
| Conversions are right | `float()` for the bill and `int()` for the people count. | 1 |
| Math is right | Per-person amount equals bill divided by people. | 1 |
| Readable output | Three labelled lines, easy to glance at. | 1 |