Question 5: Input

Write a Python program to find out how many marbles a child has collected.

  • Start by asking for the child’s name and store it in a variable called name.
  • Ask how many red marbles they have and store it in a variable called red_marbles (as an integer).
  • Ask how many blue marbles they have and store it in a variable called blue_marbles (as an integer).
  • Ask how many green marbles they have and store it in a variable called green_marbles (as an integer).
  • Calculate the total number of marbles by adding red_marbles, blue_marbles, and green_marbles and store it in a variable called total_marbles.
  • Print a message that includes the child’s name and the total number of marbles in a friendly sentence, like this: “Hi [name]! You have collected a total of [total_marbles] marbles.”
Write what you are looking for, and press enter to begin your search!