Question 11: Operators

Emma runs a bookstore. She bought 50 books for $4 each and sold them for $6 each. Write a Python program to calculate the profit Emma made from selling the books.

  • Start by asking for Emma’s name and store it in a variable called name.
  • Define variables for the number of books bought and sold, their purchase price, and their selling price:
    • Store the number of books in a variable called num_books and set it to 50.
    • Store the purchase price of each book in a variable called purchase_price and set it to 4.
    • Store the selling price of each book in a variable called selling_price and set it to 6.
  • Calculate the total cost by multiplying the number of books by the purchase price.
  • Calculate the total revenue by multiplying the number of books by the selling price.
  • Calculate the profit by subtracting the total cost from the total revenue.
  • Print a message that includes Emma’s name and the profit she made in a friendly sentence.
Write what you are looking for, and press enter to begin your search!