Question

In: Computer Science

Use Python to solve: show all code: 2) For the last assignment you had to write...

Use Python to solve: show all code:

2) For the last assignment you had to write a program that calculated and displayed the end of year balances in a savings account if $1,000 is put in the account at 6% interest for five years.

The program output looked like this:

Balance after year 1 is $ 1060.0

Balance after year 2 is $ 1123.6

Balance after year 3 is $ 1191.02

Balance after year 4 is $ 1262.48

Balance after year 5 is $ 1338.23

Modify your code so that it displays the balances for interest rates from three to five percent inclusive, in one percent intervals. (Hint: Use an outer loop that iterates on the interest rate, and an inner one that iterates on the year.)

Output:

Interest rate of 3 %:

Balance after year 1 is $ 1030.0

Balance after year 2 is $ 1060.9

Balance after year 3 is $ 1092.73

Balance after year 4 is $ 1125.51

Balance after year 5 is $ 1159.27

Interest rate of 4 %:

Balance after year 1 is $ 1040.0

Balance after year 2 is $ 1081.6

Balance after year 3 is $ 1124.86

Balance after year 4 is $ 1169.86

Balance after year 5 is $ 1216.65

Interest rate of 5 %:

Balance after year 1 is $ 1050.0

Balance after year 2 is $ 1102.5

Balance after year 3 is $ 1157.62

Balance after year 4 is $ 1215.51

Balance after year 5 is $ 1276.28

Solutions

Expert Solution

Program:

# set the balance in the account
balanceInAccount = 1000.0
# outer loop that interates for rates on interest
for interest in range(3, 6):
    # display header
    print("Interest rate of " + str(interest) + "%:")
    balanceWithInterest = balanceInAccount
    # inner loop that interates for year
    for year in range(1, 6):
        # compute the balance with interest
        balanceWithInterest = balanceWithInterest + (balanceWithInterest * interest/100.00)
        # display the balance
        print ("Balance after year " + str(year) + " is ${0:.2f}".format(balanceWithInterest))

Output:

Program Screenshot:


Related Solutions

Use Python to solve, show all code Write a program that sums a sequence of integers...
Use Python to solve, show all code Write a program that sums a sequence of integers from a starting integer to and ending integer. The sequence is generated by skipping a value (e.g. 1,3,5,… or 2,6,10,14…). Prompt the user for a) a starting value greater than 0. Validate the value is greater than 0. b) the ending value. c) the value to skip Print out the sum of the numbers for the sequence. If the starting value is 2, the...
Use Python to solve: show all work 1) Write a program that prints out a deck...
Use Python to solve: show all work 1) Write a program that prints out a deck of cards, in the format specified below. (That is, the following should be the output of your code). 2 of hearts 2 of diamonds 2 of spades 2 of clubs 3 of hearts 3 of diamonds 3 of spades 3 of clubs 4 of hearts 4 of diamonds 4 of spades 4 of clubs Continue with 5,6,7.. ending with A of hearts A of...
User Python to solve; show all code: A user will enter in data for a basketball...
User Python to solve; show all code: A user will enter in data for a basketball team. For each player on the team the user will enter The player’s last name The average number of point the player scored last season The number of games the player is projected to play in this year Write a program that will prompt the user for the player data described above. The user does not know how many players are on the team...
Answer question in Python, show all code 2) Recall the palindrome problem. Write a new program...
Answer question in Python, show all code 2) Recall the palindrome problem. Write a new program that prompts the user for a string and checks to see if that string is a palindrome. For this updated program, input strings may have punctuation marks, spaces, and capitalizations, but these are ignored in the palindrome check. Here are some sample interactions. Please enter a string to check: A man, a plan, a canal: Panama! The string "A man, a plan, a canal:...
Use python programming to write this code and provide a screen short for the code. 2....
Use python programming to write this code and provide a screen short for the code. 2. Write a function that takes one argument (a string) and returns a string consisting of the single character from that string with the largest value. Your function should contain a for loop. You can assume that the input to your function will always be a valid string consisting of at least one character. You can assume that the string will consist only of lower-case...
HOW WOULD YOU WRITE THIS IN PYTHON? SHOW THIS IN PYTHON CODE PLEASE # DEFINE 'all_keywords',...
HOW WOULD YOU WRITE THIS IN PYTHON? SHOW THIS IN PYTHON CODE PLEASE # DEFINE 'all_keywords', A LIST COMPRISED OF ALL OUR NEGATIVE SEARCH KEYWORDS AS REQUIRED BY THE PROJECT # FOR EACH ELEMENT IN 'full_list' (THE LIST OF LISTS YOU WOULD HAVE CREATD ABOVE THE PREVIOUS LINE) # INITIALIZE THE SET 'detected_keywords' TO EMPTY # DEFINE VARIABLE 'current_reviewer' FROM CURRENT ELEMENT OF 'full_list' BY EXTRACTING ITS FIRST SUB-ELEMENT,... # ...CONVERTING IT TO A STRING, AND THEN STRIPPING THE SUBSTRING...
Answer question in Python, show all code: Write a program that calculates and displays the end...
Answer question in Python, show all code: Write a program that calculates and displays the end of year balances in a savings account if $1,000 is put in the account at 6% interest for five years. For this problem, assume interest is calculated annually. (That is, if I put $1000 in a bank account at the beginning of the year, then the balance at the end of the year is $1,000 + $1,000*6%.) You may assume no money is removed...
Write the code in python only. You will need the graphics library for this assignment. Please...
Write the code in python only. You will need the graphics library for this assignment. Please download the library and place it in the same file as your solution. Draw a 12" ruler on the screen. A ruler is basically a rectangular outline with tick marks extending from the top edge. The tick marks should be drawn at each quarter-inch mark. Below the tick marks, your ruler should show large integers at each full-inch position.
In this assignment you will start with Python code that builds a 2 host network connected...
In this assignment you will start with Python code that builds a 2 host network connected by a legacy router. You will modify it such that the two hosts can send packets to each other. It requires that you understand subnet addressing and the function of a router. The network built using Miniedit on a Mininet virtual machine: python mininet/examples/miniedit.py. We need to also make 6 static routes to make the program work. This is the work that I have...
1. Please use Python 3 programing. 2. Please share your code. 3. Please show all outputs....
1. Please use Python 3 programing. 2. Please share your code. 3. Please show all outputs. Create a GUI Calculator with the following: Title : Calculator Label and Entry box for 1st Number Label and Entry box for 2nd Number Buttons for *, /, +, - Label for result and Displaying the result
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT