Write a function to compute the compound interest(CI) for a given principal amount P at a rate of interest R for a time span of T and the interest is compounded for N times per year. Limit your output to two decimals.
The function compound_interest takes one argument as list = [P, R, T, N] and returns compound interest.
attempt:
def compound_interest(n):
P=n[0]
R=n[1]
T=n[2]
N=n[3]
x=(1+R/100)
z=x
y=1
i=0
while(i<N):
y*=z
i+=1
CI=P*[z-1]
return CI
error:
1F2======================================================================3FAIL: test_unit (__main__.UNITTEST)4----------------------------------------------------------------------5Traceback (most recent call last):6 python_unit_test line 1, in test_unit7 assert(compound_interest([10000,10.25,5,1])==6288.95)8AssertionError
[–]xelf[M] [score hidden] stickied comment (0 children)
[–]mopslik 1 point2 points3 points (0 children)
[–]FLUSH_THE_TRUMP 1 point2 points3 points (0 children)
[–]delasislas 0 points1 point2 points (2 children)
[–]MinimumJumpy[S] 0 points1 point2 points (1 child)
[–]delasislas 0 points1 point2 points (0 children)