Question 14: Operators

Max bought school supplies for his new school year. He bought 3 notebooks for $4 each, 5 pens for $1 each, and a backpack for $20. Write a Python program to calculate the total amount Max spent on school supplies.

  • Start by asking for Max’s name and store it in a variable called name.
  • Define variables for the number of each type of school supply and their respective prices:
    • Store the number of notebooks in a variable called num_notebooks and set it to 3.
    • Store the price of each notebook in a variable called notebook_price and set it to 4.
    • Store the number of pens in a variable called num_pens and set it to 5.
    • Store the price of each pen in a variable called pen_price and set it to 1.
    • Store the price of the backpack in a variable called backpack_price and set it to 20.
  • Calculate the total cost of notebooks by multiplying num_notebooks by notebook_price.
  • Calculate the total cost of pens by multiplying num_pens by pen_price.
  • Calculate the total amount spent by adding the total notebook cost, total pen cost, and backpack_price.
  • Print a message that includes Max’s name and the total amount spent in a friendly sentence.
Write what you are looking for, and press enter to begin your search!