# This program takes the original principal,# calculates the annual interest rate# calculates the number of times the interest is compounded# calculates how many years the account will earn interest# and lastly displays the ending principal# Input the original principal.original_principal=int(input('Enter the starting principal: '))# Input the annual interest rate.annual_interest=float(input('Enter the annual interest rate (%): '))annual_interest=annual_interest/100# Input times per year the interest is compounded.compound=int(input('How many times per year is the interest compounded? '))# Input number of years account will earn interest.total_years=int(input('For how many years will the account earn interest? '))# Calculate ending principle amount after earning annual# interest for a specified amount of years.ending_principal=(original_principal*(1+annual_interest/compound)**(compound*total_years))# Display the ending principle amount.print('At the end of ',total_years,'years you will have $',format(ending_principal,'.2f'))
python复利计算_使用Python的每月复利计算
最新推荐文章于 2023-12-21 09:56:59 发布