Question 17: Operators

Profit or Loss Calculation for Electronics Store

James owns an electronics store and decided to purchase 1500 smartphones at a price of $400 each. He then sold each smartphone for $500. Write a Python program to calculate whether James made a profit or a loss, how many smartphones were sold, and how many are left unsold.

  • Start by asking for James’s name and store it in a variable called name.
  • Define variables for:
    • The number of smartphones purchased (num_purchased), set to 1500.
    • The cost price of each smartphone (cost_price), set to $400.
    • The selling price of each smartphone (selling_price), set to $500.
    • The number of smartphones sold (num_sold), ask the user to input this number.
  • Calculate:
    • The total cost by multiplying the number of smartphones purchased by the cost price.
    • The total revenue by multiplying the number of smartphones sold by the selling price.
    • The profit or loss by subtracting the total cost from the total revenue.
    • The number of smartphones left unsold by subtracting the number of smartphones sold from the total number purchased.
  • Print a message that includes:
    • Whether James made a profit or loss.
    • The total number of smartphones sold.
    • The number of smartphones left unsold.

This program will help James understand his profit or loss and track his stock.

Write what you are looking for, and press enter to begin your search!