Question 8: Input

Write a Python program to find out the net number of toy cars a child has after receiving them on multiple occasions and giving some away.

  1. Start by asking for the child’s name and store it in a variable called name.
  2. Ask how many toy cars they received on the first occasion and store it in a variable called occasion1_cars (as an integer).
  3. Ask how many toy cars they received on the second occasion and store it in a variable called occasion2_cars (as an integer).
  4. Calculate the total number of toy cars they have by multiplying occasion1_cars and occasion2_cars.
  5. Ask how many toy cars they lost or gave away and store it in a variable called lost_cars (as an integer).
  6. Subtract the lost_cars from the total number of toy cars to get the net number of cars.
  7. Store the net number of cars in a variable called net_cars.
  8. Print a message that includes the child’s name and the net number of toy cars in a friendly sentence, like this: “Hi [name]! You have a net total of [net_cars] toy cars after accounting for the ones you lost or gave away.”
Write what you are looking for, and press enter to begin your search!