cs/practical-file/questions/question_17.py
2025-06-24 02:37:47 +05:30

14 lines
510 B
Python

# Question: Write a Python program to accept cost price and selling price, then print whether there is profit, loss, or no gain.
def main(cost_price: float, selling_price: float) -> None:
if selling_price > cost_price:
print(f"Profit: {selling_price - cost_price}")
elif selling_price < cost_price:
print(f"Loss: {cost_price - selling_price}")
else:
print("No gain, no loss.")
if __name__ == '__main__':
main(100.0, 120.0)
main(150.0, 130.0)
main(200.0, 200.0)