Question 18: If Else

A group of friends decided to spend a day practicing good behavior by helping others in their community. Each friend had $200 saved up. Write a Python program to calculate how much each friend has left after contributing to different charitable activities.

Start by defining the initial amount saved as saved_amount and set it to 200.

  • Ask each friend how much they donated to a local charity and store it in charity_donation.
  • Ask how much they spent buying gifts for the elderly in their neighborhood and store it in gifts_cost.
  • Ask how much they spent organizing a community clean-up event and store it in cleanup_cost.
  • Ask how much they spent on refreshments for volunteers and store it in refreshments_cost.
  • Calculate the total amount spent by adding up charity_donation, gifts_cost, cleanup_cost, and refreshments_cost.
  • Subtract the total amount spent from saved_amount to find the remaining balance.
  • Use an if condition to check if the remaining balance is positive or if they spent more than they saved.
  • Print a message that tells them how much money they have left and whether they have any savings left or if they spent more than they saved.
Write what you are looking for, and press enter to begin your search!