Question 5: Operators

Alex is shopping for a new school semester. He bought a backpack for $60, notebooks for $20, and pens for $10. He also used a discount coupon that saved him $15. Write a Python program to calculate the total money Alex spent after the discount.

  • Start by asking for Alex’s name and store it in a variable called name.
  • Define variables for the costs of the backpack, notebooks, and pens:
    • Store the cost of the backpack in a variable called backpack_cost and set it to 60.
    • Store the cost of the notebooks in a variable called notebooks_cost and set it to 20.
    • Store the cost of the pens in a variable called pens_cost and set it to 10.
  • Define a variable for the discount amount and set it to 15.
  • Calculate the total amount spent before the discount by adding backpack_cost, notebooks_cost, and pens_cost.
  • Subtract the discount amount from the total amount to get the final amount spent.
  • Store the final amount in a variable called total_spent.
  • Print a message that includes Alex’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 school supplies.”
Write what you are looking for, and press enter to begin your search!