python calculations

Performing Compound Interest Calculations in Python

Introducing how to perform compound interest calculations for investments using the Python programming language. The value when starting with 600,000 yen and continuing with 10% annual profit for 10 years...

Shou Arisaka
1 min read
Oct 14, 2025

Introducing how to perform compound interest calculations for investments using the Python programming language.

Image

Image

The value when starting with 600,000 yen and continuing with 10% annual profit for 10 years

>>> compound_interest(600000, 10, 10)
1556245.4760600014

The value when starting with 600,000 yen and continuing with 10% annual profit for 20 years

>>> compound_interest(600000, 10, 20)
4036499.9695953666

Code


def compound_interest(principle, rate, time): 
    print( principle * (pow((1 + rate / 100), time)) )

Bash


calc_compound_interest(){

  : e.g. calc_compound_interest [principle] [rate percentage] [years]
  : e.g. calc_compound_interest 100000 10 20

python3 - $@ <<EOF
# -*- coding: utf-8 -*-

import sys
import re
args = sys.argv

def compound_interest(principle, rate, time):
    print( principle * (pow((1 + rate / 100), time)) )

compound_interest(${1}, ${2}, ${3})

EOF

}

Python Program for compound interest - GeeksforGeeks

For cases where itโ€™s monthly or quarterly rather than annually, the following equation can be used

Compound Interest Formula

Share this article

Shou Arisaka Oct 14, 2025

๐Ÿ”— Copy Links