A while loop repeats a block of code as long as a specific condition remains True
Control statements:
break: Instantly exits (stops) the loop entirely.
continue: Skips the current step and jumps straight to the next iteration.
end=" ": By default, print() adds a new line at the end. end handles what goes at the very end of the printed line (instead of a default newline). Setting end=" " tells Python to stay on the same line (using a space instead of a newline).
sep=" " : Sep (Separator): Defines what character goes between multiple items inside a single print() statement (e.g., sep="-").
Write an interactive Python program that simulates an automated vending machine running in a continuous loop:
The Menu: Display the vending machine item list with exact codes and prices, plus an option to "EXIT" and checkout.
User Selection: Prompt the user for a choice. Use a match-case statement to handle valid codes by adding the item price to a running total, or handle the "EXIT" command to break out of the loop.
Checkout: When the user exits, display their final total amount due.
==================================================
SMART VENDING MACHINE - ITEM LIST
==================================================
[A1] Chocolate Bar - $1.25
[B2] Potato Chips - $1.50
[C3] Sparkling Water - $2.00
[D4] Gummy Bears - $1.75
[EXIT] Checkout and Finish
--------------------------------------------------
Enter code or EXIT: B2
-> Added: Potato Chips ($1.50)
Enter code or EXIT: C3
-> Added: Sparkling Water ($2.00)
Enter code or EXIT: D4
-> Added: Gummy Bears ($1.75)
Enter code or EXIT: D4
-> Added: Gummy Bears ($1.75)
Enter code or EXIT: EXIT
==================================================
Final Total Due: $7.0
Thank you for using Smart Vending Machine!
==================================================