0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Return on Investment (ROI) Formula - Python Code

Posted at

Return on Investment (ROI) Formula

ROI = \frac{\text{Gain from Investment} - \text{Cost of Investment}}{\text{Cost of Investment}} \times 100%

where:
Gain from Investment is the amount of money gained from the investment
Cost of Investment is the initial cost of the investment

Python Code

return_on_investment.py
def return_on_investment(gain, cost):
    roi = (gain - cost) / cost * 100
    return roi


gain = 2400
cost = 2000

roi = return_on_investment(gain, cost)

print("Return on investment: {:.2f}%".format(roi))

# Output: Return on investment: 20.00%
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?