Question 1: Operators John Bicycle

John bought a bicycle for $250 and a helmet for $50. Later, he sold the bicycle for $400. Write a Python program to calculate how much profit John made from selling his bicycle.

Start by asking for John’s name and store it in a variable called name.
Define variables for the costs:

  • Store the cost of the bicycle in a variable called cost_of_bicycle and set it to 250.

  • Store the cost of the helmet in a variable called cost_of_helmet and set it to 50.

  • Store the selling price of the bicycle in a variable called selling_price_of_bicycle and set it to 400.

Calculate the total amount John spent by adding the cost of the bicycle and the cost of the helmet.
Calculate the profit by subtracting the total amount spent from the selling price of the bicycle.
Store the profit in a variable called profit.
Print a message that includes John’s name and the profit in a friendly sentence, like this:
“Hi [name]! You made a profit of $[profit] from selling your bicycle.”

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