Question 7: Input

Write a Python program to find out the net number of toy cars a child has after some additions and subtractions.

  • Start by asking for the child’s name and store it in a variable called name.
  • Ask how many toy cars they received as a gift and store it in a variable called gift_cars (as an integer).
  • Ask how many toy cars they bought and store it in a variable called bought_cars (as an integer).
  • Ask how many toy cars they gave away and store it in a variable called gave_away_cars (as an integer).
  • Calculate the total number of toy cars they have by adding gift_cars and bought_cars.
  • Subtract the gave_away_cars from the total number of toy cars to get the net number of cars.
  • Store the net number of cars in a variable called net_cars.
  • 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!