In this activity, we will design an algorithm and flowchart first, then write a Python program that calculates whether a transaction results in a profit, a loss, or breaks even.

Understanding Profit & Loss
Profit & Loss Formulas
Algorithm
- START
- INPUT: Ask the user for the Cost Price (CP)
- INPUT: Ask the user for the Selling Price (SP)
- DECISION: Is SP greater than CP?
- YES → Calculate Profit = SP - CP, OUTPUT: Print profit amount
- NO → DECISION: Is SP less than CP?
- YES → Calculate Loss = CP - SP, OUTPUT: Print loss amount
- NO → OUTPUT: Print 'Break Even — no profit or loss'
- END

Writing the Python Code
# Profit and Loss Calculator cp = float(input("Enter the Cost Price: ")) sp = float(input("Enter the Selling Price: ")) if sp > cp: profit = sp - cp print("Profit: " + str(profit)) elif sp < cp: loss = cp - sp print("Loss: " + str(loss)) else: print("Break Even — no profit or loss")
Understanding the Code
Code Breakdown
Testing the Program
- Run the program and enter CP = 500, SP = 700 → Should print Profit: 200.0
- Run again with CP = 800, SP = 600 → Should print Loss: 200.0
- Run again with CP = 500, SP = 500 → Should print Break Even

Save your file with the name Profit and Loss Calculator before moving on!

.webp&w=3840&q=75)
.webp&w=3840&q=75)
.webp&w=3840&q=75)
.webp&w=3840&q=75)
.webp&w=3840&q=75)