Question 10: Input

Write a Python program to find out the net number of toy cars a child has after receiving them in multiple sets 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 sets of toy cars they received, and store this value in a variable called sets_received (as an integer).
  3. Ask how many toy cars are in each set, and store this value in a variable called cars_per_set (as an integer).
  4. Calculate the total number of toy cars they have by multiplying sets_received and cars_per_set.
  5. Ask how many additional individual toy cars they received as gifts and store it in a variable called gift_cars (as an integer).
  6. Add gift_cars to the total number of toy cars calculated in step 4.
  7. Ask how many toy cars they gave away and store it in a variable called gave_away_cars (as an integer).
  8. Subtract gave_away_cars from the total number of toy cars to get the net number of cars.
  9. Store the net number of cars in a variable called net_cars.
  10. 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 gave away.”
Write what you are looking for, and press enter to begin your search!