Skip to content
CAGR Calculators

CAGR Calculators

CAGR Calculator | Reverse CAGR Calculator

  • CAGR Calculator
  • Reverse CAGR Calculator
  • NPV Calculator
  • IRR Calculator
  • Future Value of Annuity Calculator
  • Blog
  • Toggle search form
def cagr - how to calculate cagr in python

def CAGR: How To Calculate CAGR in Python By Defining 1 Easy Function

Posted on By

CAGR stands for Compound Annual Growth Rate. It is the average annual growth rate of a numeric value (can be an investment, population, or anything else that can be measured in numbers) during a multi-year time period.

The CAGR formula is the following: { [Final Amount] / [Initial Amount] } ^ (1 / Years) – 1

Let’s see how we can use this formula in Python.

cagr formula

See also: How To Calculate CAGR in Excel, How To Calculate CAGR in Google Sheets

def CAGR(): How To Calculate CAGR in Python In 2 Easy Steps

In Python, we can create a simple function using the CAGR formula above to calculate the Compound Annual Growth Rate.

We can create the function using ‘def cagr’ and allow for 3 inputs to the function – initial_value, final_value, and no. of years. Note that the ‘raised to the power of‘ is represented by ‘**‘ in Python.

def cagr(initial_value, final_value, years):
    cagr = (final_value / initial_value) ** (1/years) - 1
    return cagr

After defining the cagr function, when we need to calculate the CAGR, we can call the function cagr and supply the three numerical input values for initial value, final value, and no. of years. For example, let’s say I want to find the CAGR of a $100,000 investment that grows to $200,000 in 10 years, I will write the following code.

CAGR = cagr(100000,200000,10)
print(CAGR*100)

The function calculates and sends out the CAGR (7.18%) which we can print and view on screen.

def CAGR(): How To Calculate CAGR in Python

def cagr() – how to calculate cagr in python by creating a function

You can cross-verify the answer by using our online CAGR Calculator to make sure the def cagr() function is set up properly.

def CAGR(): How To Calculate CAGR in Python
def cagr - how to calculate cagr in python

CAGR Calculator | Reverse CAGR Calculator | Blog Posts

Learn Personal Finance

Check out our new venture multipl !

More From The Blog

Russell 2000 CAGR: The Compound Annual Growth Rate of Russell 2000 Index
CAGR Calculator

Russell 2000 CAGR: The Compound Annual Growth Rate of Russell 2000 Index

GDP CAGR: Historical GDP Growth Rate Of 6 Major Economies of 2023
CAGR Calculator

GDP CAGR: Historical GDP Growth Rate Of 6 Major Economies of 2023

CAGR Formula in Google Sheets: 2 Easy Methods To Calculate CAGR in Google Sheets
CAGR Calculator

CAGR Formula in Google Sheets: 2 Easy Methods To Calculate CAGR in Google Sheets

Bitcoin CAGR: Compound Annual Growth Rate of Bitcoin
CAGR Calculator

Bitcoin CAGR: Compound Annual Growth Rate of Bitcoin

UK Stock Market CAGR: Average UK Stock Market Returns In Last 30 Years
CAGR Calculator

UK Stock Market CAGR: Average UK Stock Market Returns In Last 30 Years

Nasdaq CAGR: The Compound Annual Growth Rate of Nasdaq Composite Index
CAGR Calculator

Nasdaq CAGR: The Compound Annual Growth Rate of Nasdaq Composite Index

Stock Market CAGR Returns: Average Annual Stock Market Returns In Last 30 Years
CAGR Calculator

Stock Market CAGR Returns: Average Annual Stock Market Returns In Last 30 Years

Population CAGR: India vs China Population Growth Rate In Last 60 Years
CAGR Calculator

Population CAGR: India vs China Population Growth Rate In Last 60 Years

S&P 500 CAGR: The Compound Annual Growth Rate of S&P 500 Index
CAGR Calculator

S&P 500 CAGR: The Compound Annual Growth Rate of S&P 500 Index

Future Home Value Calculator: How Much Will Your Home Be Worth In 5, 10, or 20 years?
Reverse CAGR Calculator

Future Home Value Calculator: How Much Will Your Home Be Worth In 5, 10, or 20 years?

Dow Jones CAGR: The Compound Annual Growth Rate of Dow Jones Industrial Average
CAGR Calculator

Dow Jones CAGR: The Compound Annual Growth Rate of Dow Jones Industrial Average

CAGR Formula in Excel: 2 Easy Methods To Calculate CAGR in Excel
CAGR Calculator

CAGR Formula in Excel: 2 Easy Methods To Calculate CAGR in Excel

def CAGR: How To Calculate CAGR in Python By Defining 1 Easy Function
CAGR Calculator

def CAGR: How To Calculate CAGR in Python By Defining 1 Easy Function

Our Financial Calculator Apps

download loan early payoff calculator app on ios
download loan early payoff calculator app on android
download cagr calculator app on ios
download cagr calculator app on android
download reverse cagr calculator app on ios
download reverse cagr calculator app on android
download irr calculator app
download irr calculator app on ios
DOWNLOAD NPV CALCULATOR APP
DOWNLOAD NPV CALCULATOR APP

Page Contents

Toggle
  • def CAGR(): How To Calculate CAGR in Python In 2 Easy Steps
  • More From The Blog
  • Dow Jones CAGR: The Compound Annual Growth Rate of Dow Jones Industrial Average
  • GDP CAGR: Historical GDP Growth Rate Of 6 Major Economies of 2023
  • Future Home Value Calculator: How Much Will Your Home Be Worth In 5, 10, or 20 years?
  • Russell 2000 CAGR: The Compound Annual Growth Rate of Russell 2000 Index
  • CAGR Formula in Excel: 2 Easy Methods To Calculate CAGR in Excel
  • S&P 500 CAGR: The Compound Annual Growth Rate of S&P 500 Index
  • Stock Market CAGR Returns: Average Annual Stock Market Returns In Last 30 Years
  • Bitcoin CAGR: Compound Annual Growth Rate of Bitcoin
  • Nasdaq CAGR: The Compound Annual Growth Rate of Nasdaq Composite Index
  • def CAGR: How To Calculate CAGR in Python By Defining 1 Easy Function
  • Population CAGR: India vs China Population Growth Rate In Last 60 Years
  • UK Stock Market CAGR: Average UK Stock Market Returns In Last 30 Years
  • CAGR Formula in Google Sheets: 2 Easy Methods To Calculate CAGR in Google Sheets
  • Our Financial Calculator Apps
CAGR Calculator

Post navigation

Previous Post: Population CAGR: India vs China Population Growth Rate In Last 60 Years
Next Post: Stock Market CAGR Returns: Average Annual Stock Market Returns In Last 30 Years
  • CAGR Calculator: Calculate CAGR Online
  • Reverse CAGR Calculator: Calculate Future Value Online
  • NPV Calculator: Calculate Net Present Value Online
  • IRR Calculator: Calculate Internal Rate of Return Online
  • Future Value of Annuity Calculator
  • UK Stock Market CAGR: Average UK Stock Market Returns In Last 30 Years
  • GDP CAGR: Historical GDP Growth Rate Of 6 Major Economies of 2023
  • Future Home Value Calculator: How Much Will Your Home Be Worth In 5, 10, or 20 years?
  • Bitcoin CAGR: Compound Annual Growth Rate of Bitcoin
  • Nasdaq CAGR: The Compound Annual Growth Rate of Nasdaq Composite Index
  • Russell 2000 CAGR: The Compound Annual Growth Rate of Russell 2000 Index
  • Stock Market CAGR Returns: Average Annual Stock Market Returns In Last 30 Years
  • def CAGR: How To Calculate CAGR in Python By Defining 1 Easy Function
  • Population CAGR: India vs China Population Growth Rate In Last 60 Years
  • Dow Jones CAGR: The Compound Annual Growth Rate of Dow Jones Industrial Average

Reach Out To Us

contact@finlightened.com

With ❤️ From Luxembourg

Sumeet Sinha

Sitemap

Navigation

  • CAGR Calculator
  • Reverse CAGR Calculator
  • IRR Calculator
  • NPV Calculator
  • Future Value of Annuity Calculator
  • Blog
  • About Us
  • Privacy Policy

Recent Posts

  • UK Stock Market CAGR: Average UK Stock Market Returns In Last 30 Years
  • GDP CAGR: Historical GDP Growth Rate Of 6 Major Economies of 2023
  • Future Home Value Calculator: How Much Will Your Home Be Worth In 5, 10, or 20 years?
  • Bitcoin CAGR: Compound Annual Growth Rate of Bitcoin
  • Nasdaq CAGR: The Compound Annual Growth Rate of Nasdaq Composite Index
  • Russell 2000 CAGR: The Compound Annual Growth Rate of Russell 2000 Index
  • Stock Market CAGR Returns: Average Annual Stock Market Returns In Last 30 Years
  • def CAGR: How To Calculate CAGR in Python By Defining 1 Easy Function
  • Population CAGR: India vs China Population Growth Rate In Last 60 Years
  • Dow Jones CAGR: The Compound Annual Growth Rate of Dow Jones Industrial Average
  • S&P 500 CAGR: The Compound Annual Growth Rate of S&P 500 Index
  • CAGR Formula in Excel: 2 Easy Methods To Calculate CAGR in Excel
  • CAGR Formula in Google Sheets: 2 Easy Methods To Calculate CAGR in Google Sheets

Copyright © 2025 CAGR Calculators.

Powered by PressBook WordPress theme