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%