Question

In: Computer Science

write a python script to calculate 401k with compounding interest

write a python script to calculate 401k with compounding interest

Solutions

Expert Solution

Taking principle amount ,P =401k

This program will ask for the rate of interest and no.of years(n) to the user and takes the input.

The value of principle amount after n years with interest compunded anually is outputted to the user.

P=401*1000

# reading inputs from user using input() method of type int()
r=float(input("Enter rate of interest : "))
n=int(input("Enter no.of times interest is compounded per year : "))
t=int(input("Enter no.of year : "))

# Calculating amount after principle compounded n times in t years at interest rate of r
A= pow(P*(1 + (r/n)),n*t)

# Printing the final amount
print("Amount after principle compounded {}".format(n)+" times in {}".format(t)+" years at interest rate of {}".format(r)+" is : {}".format(A))

I have calculated the compunded amount "A" of principle "P" at interest rate of "r" in "t" years at "n" times per year is  

I have provide comments in the code to explain steps. Feel free to comment for any queries or if you want any modifications in the code.

I have tested the code for different inputs and the code is working fine. I am providing an output screenshot for your reference.

Thank you :)


Related Solutions

The school bookstore wants you to write a Python script to calculate the point of sale...
The school bookstore wants you to write a Python script to calculate the point of sale (total cost) of their new 25$ gift cards. They are also running a special, if a customer buys a gift card they can buy all books for 5$ dollars each. The gift card cost is $25.00 plus $5.00 per book. In addition, there is a sales tax which should be applied to the subtotal and it is 8% (multiply the subtotal by 0.08.) Requirements:...
The school bookstore wants you to write a Python script to calculate the point of sale...
The school bookstore wants you to write a Python script to calculate the point of sale (total cost) of their new 25$ gift cards. They are also running a special, if a customer buys a gift card they can buy all books for 5$ dollars each. The gift card cost is $25.00 plus $5.00 per book. In addition, there is a sales tax which should be applied to the subtotal and it is 8% (multiply the subtotal by 0.08.) Requirements:...
The school bookstore wants you to write a Python script to calculate the point of sale...
The school bookstore wants you to write a Python script to calculate the point of sale (total cost) of their new 25$ gift cards. They are also running a special, if a customer buys a gift card they can buy all books for 5$ dollars each. The gift card cost is $25.00 plus $5.00 per book. In addition, there is a sales tax which should be applied to the subtotal and it is 8% (multiply the subtotal by 0.08.) Requirements:...
Write a python script to calculate the average length of the game shortest game , longest...
Write a python script to calculate the average length of the game shortest game , longest game and the overall average length of a snake and ladder game The game length is the number of throws of the die. We are asked to write a python script which calculate that together with the average
write a python script to calculate the return of a stock with 10years of historical data/returns
write a python script to calculate the return of a stock with 10years of historical data/returns
Write a python script to calculate the average length of the game, Shortest game, longest game...
Write a python script to calculate the average length of the game, Shortest game, longest game and overall length of the game we need a python script that calculates the average length of a snake and ladder game. ie the number of moves it takes a single player to win the game. Then you run the game several times and will compare the results to come up with the required data(length of the game and number of moves )
How do I write a script for this in python in REPL or atom, NOT python...
How do I write a script for this in python in REPL or atom, NOT python shell Consider the following simple “community” in Python . . . triangle = [ ["top", [0, 1]], ["bottom-left", [0, 0]], ["bottom-right", [2, 0]], ] This is the calling of function. >>> nearestneighbor([0, 0.6], triangle, myeuclidean) 'top' The new point is (0, 0.6) and the distance function is Euclidean. Now let’s confirm this result . . . >>> myeuclidean([0, 0.6], [0, 1]) 0.4 >>> myeuclidean([0,...
write a python script for rock scissors paper game
write a python script for rock scissors paper game
Write the following Python script: Imagine you live in a world without modules in Python! No...
Write the following Python script: Imagine you live in a world without modules in Python! No numpy! No scipy! Write a Python script that defines a function called mat_mult() that takes two lists of lists as parameters and, when possible, returns a list of lists representing the matrix product of the two inputs. Your function should make sure the lists are of the appropriate size first - if not, your program should print “Invalid sizes” and return None. Note: it...
Write the following Python script: Imagine you live in a world without modules in Python! No...
Write the following Python script: Imagine you live in a world without modules in Python! No numpy! No scipy! Write a Python script that defines a function called mat_mult() that takes two lists of lists as parameters and, when possible, returns a list of lists representing the matrix product of the two inputs. Your function should make sure the lists are of the appropriate size first - if not, your program should print “Invalid sizes” and return None. Note: it...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT