Register Now

Login

Lost Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Login

Register Now

Welcome to All Test Answers

Lab 8 – Python

Lab 8(2)

Answer:

Q1


##Display the output header
print(" {0} {1}".format(" Simple Interest", " Compound Interest"))
start = 1000
simple_interest = start
compound_interest = start
##Loop through years 1 to 4
for k in range(1, 5):
    ##calculate the amount after 4 years using simple interst
    simple_interest += start*.05
    ##calculate the amount after 4 years using compound interst
    compound_interest = compound_interest*1.05
    print("{0} ${1:,.2f} ${2:,.2f}".format(k, simple_interest, compound_interest))

Q2


## starting value of the car
starting_value = 20000
##Loop through years 1 up to 4
for k in range(1, 5):
    ##calculate Automobile Depreciation 15% after each year
    starting_value = starting_value*.85
    print("{0} ${1:,.2f}".format(k, starting_value))

About

Leave a reply

Captcha Click on image to update the captcha .

error: Content is protected !!