top of page
Search

Profit Or Loss - Python Code

Hello All!

This Is WowMindz Post On "Profit Or Loss" Python Code.


This is the code :-

print("To find whether the given input is profit or loss")
a=float(input("Enter the CP "))
b=float(input("Enter the SP "))
if(a==b):
    print("OMG!! its seems its neither Profit nor Loss")
else:
    if(b>a):   
       print("Bruh!!, its a profit of ",b-a)   
    else:
        print("Oh Noooooo!, its a loss of ",a-b)
print("Did you like it then give it a like!!")

And these are formulas for profit and loss:-

  1. Profit = S.P > C.P

  2. Loss = C.P < S.P

  3. Profit = S.P - C.P

  4. Loss = C.P - S.P

Then 'a' as per the above program means C.P and 'b' is the S.P

and in if condition it says if the value b is greater than the value a it means profit as we saw in the above formula and the we would print its profit value which is S.P - C.P as we saw in formula 3 then the b-a will be printed in the run screen.

Same happens if value a is greater than value b, it will be printed loss as we saw in the if condition and its loss value.

And by chance if we get no profit no loss then it would just say its neither profit nor loss.


Now this how it looks on when there is Loss :-

To find whether the given input is profit or loss
Enter the CP 5000
Enter the SP 4000
Oh Noooooo!, its a loss of  1000.0
Did you like it then give it a like!!

And this how it looks on Profit :-

To find whether the given input is profit or loss
Enter the CP 4000
Enter the SP 5000
Bruh!!, its a profit of  1000.0
Did you like it then give it a like!!

This how when there is no profit and no loss :-

To find whether the given input is profit or loss
Enter the CP 5000
Enter the SP 5000
OMG!! its seems its neither Profit nor Loss
Did you like it then give it a like!!

Thank You!!








Check out these links :-


Website: wowmindz.com

YouTube: WowMindz

Instagram: @wowmindz

CEO's Instagram: @wowtheekum

47 views0 comments

Comments


bottom of page