Question 6: Operators

Sarah is preparing for a birthday party. She bought decorations for $50, a cake for $30, and party favors for $20. Write a Python program to calculate the total money Sarah spent on all the items.

  • Start by asking for Sarah’s name and store it in a variable called name.
  • Define variables for the costs of the decorations, cake, and party favors:
    • Store the cost of decorations in a variable called decorations_cost and set it to 50.
    • Store the cost of the cake in a variable called cake_cost and set it to 30.
    • Store the cost of party favors in a variable called party_favors_cost and set it to 20.
  • Calculate the total amount spent by adding decorations_cost, cake_cost, and party_favors_cost.
  • Store the total amount in a variable called total_cost.
  • Print a message that includes Sarah’s name and the total amount spent in a friendly sentence, like this: “Hi [name]! You spent a total of $[total_cost] on your birthday party preparations.”
Write what you are looking for, and press enter to begin your search!