Question 4: Operators

Emma is planning a garden. She bought 3 packs of seeds for $5 each, a watering can for $15, and gardening gloves for $10. She also received a $10 discount on her total purchase. Write a Python program to calculate the total money Emma spent after the discount.

  • Start by asking for Emma’s name and store it in a variable called name.
  • Define variables for the costs:
    • Store the cost per pack of seeds in a variable called seed_cost and set it to 5.
    • Store the number of seed packs in a variable called num_seeds and set it to 3.
    • Store the cost of the watering can in a variable called watering_can_cost and set it to 15.
    • Store the cost of the gardening gloves in a variable called gloves_cost and set it to 10.
    • Store the discount amount in a variable called discount and set it to 10.
  • Calculate the total cost of the seed packs by multiplying seed_cost by num_seeds.
  • Calculate the total amount before discount by adding the total seed cost, watering_can_cost, and gloves_cost.
  • Subtract the discount amount from the total amount before discount to get the final amount spent.
  • Store the final amount in a variable called total_spent.
  • Print a message that includes Emma’s name and the total amount spent after the discount in a friendly sentence, like this: “Hi [name]! After using your discount, you spent a total of $[total_spent] on your gardening supplies.”
Write what you are looking for, and press enter to begin your search!