Emily saved $150. She decided to spend some of her savings on different items. First, she bought a book. Then, she purchased some snacks. After that, she saw a toy she liked and bought it. She also needed to take a taxi ride to get home, and finally, she spent some money on a game. Write a Python program to calculate how much money Emily has left after her expenses. Use an if
condition to tell her if she still has money saved or if she spent more than she saved.
- Start by defining a variable for the initial savings and set it to $150.
- Ask Emily how much she used to buy a book and store it in a variable called
book_cost
(as an integer). - Ask how much she spent on snacks and store it in a variable called
snacks_cost
(as an integer). - Ask how much she spent on a toy and store it in a variable called
toy_cost
(as an integer). - Ask how much she spent on a taxi ride and store it in a variable called
taxi_cost
(as an integer). - Ask how much she spent on a game and store it in a variable called
game_cost
(as an integer). - Calculate the total expenses by adding
book_cost
,snacks_cost
,toy_cost
,taxi_cost
, andgame_cost
. - Calculate the amount left by subtracting the total expenses from the initial savings.
- Use an
if
condition to check if there is still money saved or if she spent more than she saved. - Print a message that tells her how much she has left and whether she still has savings or spent more than she saved.