Question 13: If Else

John has $250 saved up. He plans to spend some of this money on various activities and then split the remaining amount equally for his next few outings. Write a Python program to calculate how much money John has left after his expenses and how much money he can allocate for each outing. Use an if condition to tell him if he can still go for outings or if he spent all his money.

  1. Start by defining a variable for the initial savings and set it to $250.
  2. Ask John how much he spent on a new pair of shoes and store it in a variable called shoes_cost (as an integer).
  3. Ask how much he spent on groceries and store it in a variable called groceries_cost (as an integer).
  4. Ask how much he spent on a movie ticket and store it in a variable called movie_ticket_cost (as an integer).
  5. Ask how much he spent on a gift and store it in a variable called gift_cost (as an integer).
  6. Ask how much he spent on a meal and store it in a variable called meal_cost (as an integer).
  7. Calculate the total expenses by adding shoes_cost, groceries_cost, movie_ticket_cost, gift_cost, and meal_cost.
  8. Calculate the amount left by subtracting the total expenses from the initial savings.
  9. Ask John how many outings he wants to plan and store it in a variable called num_outings (as an integer).
  10. Calculate the amount per outing by dividing the amount left by num_outings if the amount left is greater than zero.
  11. Use an if condition to check if there is still money left to go for outings or if he spent all his money.
  12. Print a message that tells him how much he has left and whether he can go for outings or if he spent all his money.
Write what you are looking for, and press enter to begin your search!