Question 16: If Else

Sam and his friends are planning a fun summer holiday. They have saved up $250 each to spend on various activities. They want to visit a theme park, go to the movies, buy some snacks, rent bikes for a day, and go to the beach. Sam wants to know how much money he has left after all these activities.

Scenario:

Sam’s tasks involve several steps:

  1. Initial Savings:

    • Start by defining a variable for the initial savings and set it to $250.
  2. Track Expenses:

    • Ask Sam how much he spent on the theme park ticket and store it in a variable called theme_park_cost (as an integer).
    • Ask how much he spent on the movies and store it in a variable called movies_cost (as an integer).
    • Ask how much he spent on snacks and store it in a variable called snacks_cost (as an integer).
    • Ask how much he spent on renting bikes and store it in a variable called bikes_cost (as an integer).
    • Ask how much he spent on the beach trip and store it in a variable called beach_cost (as an integer).
  3. Calculate Total Expenses:

    • Calculate the total expenses by adding theme_park_cost, movies_cost, snacks_cost, bikes_cost, and beach_cost.
  4. Calculate Remaining Money:

    • Calculate the amount left by subtracting the total expenses from the initial savings.
  5. Check Savings Status:

    • Use an if condition to check if there is still money saved or if Sam spent more than he saved.
  6. Print a Message:

    • Print a message that tells Sam how much he has left and whether he still has savings or spent more than he saved.

Let’s create a Python program to help Sam with his tasks.

Write what you are looking for, and press enter to begin your search!