Python program for SIP returns . created via Chat GPT
The query I input in chatGPT:
write a program for compound interest based SIP returns. it should take user input for the monthly SIP investment, interest rate, number of years of sip. it calculates the total amount invested, total amount appreciated, and total amount at the end of each year. It also displays the breakdown of the investment at the end of each year
<start of output>
Here is a Python program that calculates compound interest based SIP returns:
----
def sip_returns(monthly_sip, interest_rate, years):
total_invested = 0
total_appreciated = 0
print("Year\tInvestment\tAppreciation\tTotal")
for year in range(1, years + 1):
investment = monthly_sip * 12
total_invested += investment
appreciation = (total_invested * interest_rate) / 100
total_appreciated += appreciation
total = total_invested + total_appreciated
print(f"{year}\t{investment}\t{appreciation}\t{total}")
monthly_sip = float(input("Enter monthly SIP investment: "))
interest_rate = float(input("Enter interest rate: "))
years = int(input("Enter number of years of SIP: "))
sip_returns(monthly_sip, interest_rate, years)
The program takes user input for the monthly SIP investment, interest rate, and number of years of SIP. It then uses a for loop to calculate the total amount invested, total amount appreciated, and total amount at the end of each year. The results are displayed in a table, with the breakdown of the investment at the end of each year.
The program assumes the interest is compounded annually. If you want to calculate the returns with different compounding frequency, you need to adjust the formula accordingly.
<end of output>
----
To run program online https://www.programiz.com/python-programming/online-compiler/
Sample Output:
Enter monthly SIP investment: 5000 Enter interest rate: 14 Enter number of years of SIP: 15
Year Investment Appreciation Total 1 60000.0 8400.0 68400.0 2 60000.0 16800.0 145200.0 3 60000.0 25200.0 230400.0 4 60000.0 33600.0 324000.0 5 60000.0 42000.0 426000.0 6 60000.0 50400.0 536400.0 7 60000.0 58800.0 655200.0 8 60000.0 67200.0 782400.0 9 60000.0 75600.0 918000.0 10 60000.0 84000.0 1062000.0 11 60000.0 92400.0 1214400.0 12 60000.0 100800.0 1375200.0 13 60000.0 109200.0 1544400.0 14 60000.0 117600.0 1722000.0 15 60000.0 126000.0 1908000.0
Comments
Post a Comment