# Python Coding - List Of Compound Interest Rates & Place It In A CSV File

A simple project idea could be to code a list of compound interest rates using python libraries. To make it more advanced, a CSV file can be coded in order to automatically transfer all the values from the codes to a neatly ordered list in a separate document.

The code is the following;

import math

import csv

import numpy as np

# Future_ci = Future compound interest

# P = Starting Principle

# r = Annual interest rate

# n = Compound interest rate

# t = Amound of years

# Future_ci = P * (((1 + ((r/100.0)/n)) ** (n*t)))

# Your personal ID is 1234

sec_num = 1234

user_num = 0

rates = [10, 20, 30]

print("Hello, welcome to Yas's Bank.")

while user_num != sec_num:

user_num = int(input("Please enter your security number: "))

if user_num == sec_num:

print("You are now vertified and can calculate your future compound interest.")

break

else:

user_num = print("The security number you entered is incorrect. Please try again. ")

price_amount = float(input("First, please enter your starting principle: "))

rate_of_int = float(input("Second, enter annual interest rate (example; 10 for 10%) "))

time_period = float(input("Finally, enter time period in years: "))

def future(price, rate, time):

future = price * (math.pow((1 + rate / 100), time))

compd = future - price

print("Compound interest for principal amount {0} = {1}")

return compd

compounds = {}

for rate in rates:

compounds[rate] = future (price_amount, rate, time_period)

print("Future Compound Interest for Principal Amount {0} at interest rate {1} = {2}".format(price_amount, rate,future(price_amount, rate_of_int, time_period)))

with open("Yas's_bank.csv", "w") as writeFile:

writer = csv.writer(writeFile)

writer.writerow(["rate", "price amount", "time_period", "future values"])

for r in compounds:

writer.writerow([str(r)+"%", str(round(price_amount, 2))+"kr", str(time_period)+"years", round(compounds[r], 2)])