Pythonプログラミング言語で投資の複利計算をする方法について紹介します。
60万円からはじめて年10%の利益を10年間続けた場合の値
>>> compound_interest(600000, 10, 10)
1556245.4760600014
60万円からはじめて年10%の利益を20年間続けた場合の値
>>> compound_interest(600000, 10, 20)
4036499.9695953666
コード
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
毎年ではなく毎月だとか四半期毎とかという場合には以下の方程式が使えそう
関連記事:
Windows 11にPythonをインストールする
Pythonのバージョン管理をする方法とpyenvの使い方
Pycharmの有料版を無料でインストールするには
Imagededupで類似画像を抽出、検出する(Python)
自然言語テキストが何語なのか判定する [fastText]
関連広告: