You are building a mini supermarket checkout system where a cashier scans items, updates quantities, applies discounts, and prints a receipt.
Ask the cashier:
Enter number of items customer is buying:
Use a loop (for with range) to collect items.
For each item:
Ask for:
Item name
Quantity
Store each item in the cart list
If quantity is more than 5, insert the new item at the beginning of the cart
Otherwise, append it to the end
Create an empty dictionary
Loop through the cart list:
Ask for price of each item
Store like:
{"Rice": 1200}
If price is divisible by 10Â
Apply 5% discount on the item price
Ask:
Do you want to update any item? (yes/no)
If yes:
Display items
Ask for item number
Ask for new quantity
Update the items
Loop through the cart
Multiply:
quantity × price
Store totals
Display:
Item Qty Price Total
--------------------------------
Rice 2 1200 2400
Beans 1 800 800
--------------------------------
Grand Total: ₦3200
Â
We’re always looking for international STEM educators to join our team. If you are interested, please send us a mail and we’ll get back to you!
If you have any questions, kindly send us a mail. Don’t forget to follow and like all our social accounts to get updates on competitions!
