In this exercise, you will write a program that lets a user spend money on cafe food and drinks using a simple looping menu. Some of the code has been written for you!
In the editor below, fill in the blanks (
________) so that the program behaves like the example screenshot below.
Remember to use the Python reference sheet to help you with your code! Click on one of the buttons below:
Need some help? Click here to reveal a video walkthrough for this task!
dollars. It should then present a simple menu where the user can type
ato buy a muffin for
bto buy a coffee for
5 dollars. The program should end when the user runs out of money.
0 dollarsor less!
starting_dollarsvariable to an integer using the
int()command, or you might get an error! What happens when you don’t convert the variable to an integer? Why do you think this happens?
Below is an example of how the program should run:
Enter starting $: 20 Current money: 20 Enter [a] to buy a muffin for $10 Enter [b] to buy a coffee for $5 Enter your choice: a Gobble gobble gobble! Current money: 10 Enter [a] to buy a muffin for $10 Enter [b] to buy a coffee for $5 Enter your choice: b Gulp gulp gulp! Current money: 5 Enter [a] to buy a muffin for $10 Enter [b] to buy a coffee for $5 Enter your choice: b Gulp gulp gulp! You've run out of money, sorry! Game over.