Monday, October 31, 2022
HomeWordPress DevelopmentPython Program to calculate Revenue Or Loss

Python Program to calculate Revenue Or Loss


View Dialogue

Enhance Article

Save Article

Like Article

View Dialogue

Enhance Article

Save Article

Like Article

Given the Value Worth(CP) and Promoting Worth(SP) of a product. The duty is to Calculate the Revenue or Loss.
Examples: 
 

Enter: CP = 1500, SP = 2000
Output: 500 Revenue

Enter: CP = 3125, SP = 1125
Output: 2000 Loss

Formulation: 
 

Revenue = (Promoting Worth - Value Worth)
Loss = (Value Worth - Promoting Worth)

 

Beneath is the required implementation: 
 

Python 3

  

def Revenue(costPrice, sellingPrice) :

  

    revenue = (sellingPrice - costPrice)

  

    return revenue

  

def Loss(costPrice, sellingPrice) :

  

    Loss = (costPrice - sellingPrice)

  

    return Loss

  

if __name__ == "__main__" :

  

    costPrice, sellingPrice = 1500, 2000

  

    if sellingPrice == costPrice :

        print("No revenue nor Loss")

  

    elif sellingPrice > costPrice :

        print(Revenue(costPrice, 

                     sellingPrice), "Revenue")

  

    else :

        print(Loss(costPrice, 

                   sellingPrice), "Loss")

OUTPUT : 
 

500 Revenue

Time Complexity: O(1)
Auxiliary Area: O(1)
 

Please refer full article on Program to calculate Revenue Or Loss for extra particulars!

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments