# Python&Excel: 複利を計算

### II.Pythonの場合

#### 現在の定期預金の金利0.01%の場合

Runをクリックするとグラフが表示されます。
また、IPython Shellをクリックすると利子の表が表示されます。

   import matplotlib.pyplot as plt import pandas as pd # put starting principle and rate of interest principal = 100000 interest = .0001 my_df= [] for year in range(0,11): d = { 'return': principal * ( 1.0 + interest ) ** year, 'year':year, } my_df.append(d) my_df = pd.DataFrame(my_df) print(my_df) my_df.plot.bar(x='year', y='return', rot=0, colormap='Paired', title='Compound Interest 0.01%' ) plt.show()     

バブル時の金利8.0%の場合

   import matplotlib.pyplot as plt import pandas as pd # put starting principle and rate of interest principal = 100000 interest = .080 my_df= [] for year in range(0,11): d = { 'return': principal * ( 1.0 + interest ) ** year, 'year':year, } my_df.append(d) my_df = pd.DataFrame(my_df) print(my_df) my_df.plot.bar(x='year', y='return', rot=0, colormap='Paired', title='Compound Interest 8% in the bubble economy period' ) plt.show()     

   import matplotlib.pyplot as plt import pandas as pd# put starting principle and rate of interest principal = 100000 interest = .038 my_df= [] for year in range(0,11): d = { 'return': principal * ( 1.0 + interest ) ** year, 'year':year, } my_df.append(d) my_df = pd.DataFrame(my_df) print(my_df) my_df.plot.bar(x='year', y='return', rot=0, colormap='Paired', title='Compound Interest 3.8% with a credit-card loan' ) plt.show()