What you'll build
Practice if / elif / else by working out the fee for sending mobile money. The math is honest, the decisions branch three ways.
Requirements
The must-do parts. If any are missing, we'll ask you to take another pass.
- Ask the user how much money they want to send, then convert the answer to a float.
- Calculate the fee using these rules: under GHS 100 = GHS 1 flat. From GHS 100 to GHS 499.99 = 1% of the amount. GHS 500 and above = GHS 6 flat.
- Print the amount, the fee, and the total the sender will pay — each on its own line.
- If the amount is zero or negative, print a friendly message and stop without crashing.
Bonus, if you're feeling brave
- Ask whether the recipient is on the same network (yes/no). If no, double the fee.
- Round the fee to two decimal places so the output looks like money.
Examples
What your program should look like when it runs. Lines starting with $ are typed by you; the rest is your program.
Example 1 — small send
$ python momo_fee.py
How much do you want to send (GHS)? 40
Amount: 40.0
Fee: 1.0
Total to pay: 41.0Example 2 — bad input
$ python momo_fee.py
How much do you want to send (GHS)? -5
That amount doesn't make sense. Try again.Where to start
Copy this scaffold into a new file. You don't have to use it — it's just a friendly nudge.
momo_fee.py
# Mobile money fee calculator
amount_text = input("How much do you want to send (GHS)? ")
amount = float(amount_text)
if amount <= 0:
print("That amount doesn't make sense. Try again.")
else:
# TODO: work out the fee with if/elif/else
fee = 0
total = amount + fee
print("Amount:", amount)
print("Fee:", fee)
print("Total to pay:", total)How 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 | Handles a normal send like GHS 200 without errors. | 1 |
| Branches correctly | All three bands (under 100, 100–499, 500+) produce the right fee. | 1 |
| Handles bad input | Zero or negative amounts get a calm message, not a crash. | 1 |
| Readable output | Three labelled lines a normal person could understand. | 1 |