Question 11: If Else

Michael received a gift of $200 for his birthday. He decided to use this money to buy different items and also to split some of the money for a future investment. First, he bought a gadget. Then, he purchased some clothes. After that, he treated himself to a nice meal. He also decided to donate some money to charity. Finally, he decided to split the remaining money into equal parts for a future investment. Write a Python program to calculate how much money Michael has left after his expenses and how much money each investment part will get. Use an if condition to tell him if he can still invest or if he spent all his money.

  1. Start by defining a variable for the initial gift amount and set it to $200.
  2. Ask Michael how much he used to buy a gadget and store it in a variable called gadget_cost (as an integer).
  3. Ask how much he spent on clothes and store it in a variable called clothes_cost (as an integer).
  4. Ask how much he spent on a meal and store it in a variable called meal_cost (as an integer).
  5. Ask how much he donated to charity and store it in a variable called charity_donation (as an integer).
  6. Calculate the total expenses by adding gadget_cost, clothes_cost, meal_cost, and charity_donation.
  7. Calculate the amount left by subtracting the total expenses from the initial gift amount.
  8. Ask Michael how many parts he wants to split the remaining money into and store it in a variable called num_parts (as an integer).
  9. Calculate the amount per part by dividing the amount left by num_parts if the amount left is greater than zero.
  10. Use an if condition to check if there is still money left to invest or if he spent all his money.
  11. Print a message that tells him how much he has left and whether he can invest the money into parts or if he spent all his money.
Write what you are looking for, and press enter to begin your search!