Question

Write a program in Python that computes the interest accrued on an account. You can modify...

Write a program in Python that computes the interest accrued on an account.

  • You can modify the “futval.py” program given in Chapter 2 to accomplish it. Your program should use a counted loop rather than a formula.
  • It should prompt the user to enter the principal amount, the yearly interest rate as a decimal number, the number of compounding periods in a year, and the duration.
  • It should display the principal value at the end of the duration.
    • To compute the value in 10 years for example, the program should loop 10 * periods times and accrue rate /period interest on each iteration.
    • If the principal is $1,000.00, yearly interest rate is 0.04 (4%), compounding periods in a year are 4, and the duration is 10 years, then the program should display $1488.86.

futval.py

def main():
   print(" This Program calculates the future value")
   print(" of a 10-year investment. ")
   principal = eval(input("Enter the initial principal: "))
   apr = eval(input("Enter the initial principal: "))
   for i in range(10):
       principal = principal *(1 +apr)
       print("The value in 10 years is:",principal)
       main()

0 0
Add a comment Improve this question Transcribed image text
Answer #1
def main():
    print("This program calculates the future value of a n-year investment.")
    n = int(input("Enter the number of years n: "))
    num_periods = int(input("Enter number of compounds periods in an year: "))
    principal = float(input("Enter the initial principal: "))
    apr = float(input("Enter the annual interest rate: ")) / num_periods
    for i in range(n * num_periods):
        principal = principal * (1 + apr)
    print("The value in 10 years is: {:.2f}".format(principal))


main()

Add a comment
Know the answer?
Add Answer to:
Write a program in Python that computes the interest accrued on an account. You can modify...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a program that prints the accumulated value of an initial investment invested at a specified...

    Write a program that prints the accumulated value of an initial investment invested at a specified annual interest and compounded annually for a specified number of years. Annual compounding means that the entire annual interest is added at the end of a year to the invested amount. The new accumulated amount then earns interest, and so forth. If the accumulated amount at the start of a year is acc_amount, then at the end of one year the accumulated amount is:...

  • PROGRAMMING IN C. 1) The first program will compute compounded interest. Suppose you invest $1000.00 at...

    PROGRAMMING IN C. 1) The first program will compute compounded interest. Suppose you invest $1000.00 at an interest rate of 2% per year. If the interest is computed at the end of each day, it is added to your account (i.e., the interest is compounded daily). Print what the account value will be at the end of each year for 20 years. Use data type double for money. For 365 days per year (ignore leap year), the daily interest rate...

  • 1. Using Python write a function for compounding interest. There should be three arguments to the...

    1. Using Python write a function for compounding interest. There should be three arguments to the function: a starting amount, a total interest rate, and the number of compounding periods. The function returns the ending value. Notes: normally, interest rates are given per period, or annually. The total interest rate would be the per-period interest rate multiplied by the number of compounding periods. Or in your function, the per-period interest added is the total rate divided by the number of...

  • Chapter 2 slides 40 to 47 discuss an example program, which computes the future value of...

    Chapter 2 slides 40 to 47 discuss an example program, which computes the future value of an investment given an initial principal and an interest rate. Your task is to modify this program to calculate and print the future values of an investment after 10 years, using several different interest rates.: from 1% to 20%, in increments of 1%. That is, given an initial principal, your program should compute the future value after 10 years given an interest rate of...

  • Please I wish you use Python 3.7 for this problems. Q1. Write a program that receives...

    Please I wish you use Python 3.7 for this problems. Q1. Write a program that receives a series of numbers from the user and allows the user to press the enter key to indicate that he or she is finished providing inputs. After the user presses the enter key, the program should print the sum of the numbers and their average. Q2. The credit plan at TidBit Computer Store specifies a 10% down payment and an annual interest rate of...

  • in C# Assignment #2: Millionaire Write a program that takes as input the amount of money...

    in C# Assignment #2: Millionaire Write a program that takes as input the amount of money deposited as well as the current rate of interest as a percent. The program should then determine the number of years it will take before becoming a millionaire. Make sure that you include the following error checking to ensure that both the Principal and interest rate are positive real numbers. Hints: • Ensure that Rate of Interest is a decimal (divide by 100) •...

  • Write them in python IDLE ***** 5. Average Rainfall Write a program that uses nested loops...

    Write them in python IDLE ***** 5. Average Rainfall Write a program that uses nested loops to collect data and calculate the average rainfall over a period of years. The program should first ask for the number of years. The outer loop will iterate once for each year. The inner loop will iterate twelve times, once for each month. Each iteration of the inner loop will ask the user for the inches of rainfall for that month. After all iterations,...

  • Write a Python program that computes the fuel efficiency of a multi-leg journey. The program will...

    Write a Python program that computes the fuel efficiency of a multi-leg journey. The program will first prompt for input for the starting odometer reading and then get information about the series of legs on the journey. For each leg, the user enters the current odometer reading and the amount of fuel used in liters (separated by a blank space). The user signals the end of the trip with a blank line. The program should print out the kilometers per...

  • 14.Compound Interest hank account pays compound interest, it pays interest not only on the principal amount...

    14.Compound Interest hank account pays compound interest, it pays interest not only on the principal amount that was deposited into the account, but also on the interest that has accumulated over time. Suppose you want to deposit some money into a savings account, and let the account earn compound interest for a certain number of years. The formula for calculating the balance of the account afer a specified namber of years is The terms in the formula are A is...

  • For this lab, modify the python code below so it will continuously be asking user for...

    For this lab, modify the python code below so it will continuously be asking user for inputs to calculate the interest earned until the user enters number 0 (zero) in principle. Once the user enters any number less or equal to 0 in principle, the program will end. here is my code: # Programming Exercise 3-14 # Local variables p = 0.0 r = 0.0 n = 0.0 t = 0.0 loop = True while loop: p = float(input('\nEnter the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
Active Questions
ADVERTISEMENT