Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

python 3 PROBLEM 2 Write a program that isks the user to enter an interest rate (in percentage), and then uses a while loop to

python 3 image text in transcribed
PROBLEM 2 Write a program that isks the user to enter an interest rate (in percentage), and then uses a while loop to output the number of years it takes for the investment to double at that rate. The program should prompt the user whether or not they want to continue running the program. If the user types yes, the program should repeat (.e. ask for another interest rate and output the number of years it takes for the investment to double at that rate). The program should terminate once the user types no. For this exercise, we will simply assume that the initial investment is equal to $1 because the amount of the initial investment does not matter since the percentage rate of growth of the invest- ment will be the same regardless of the initial amount deposited. An example output is shown below Enter the annual interest rate (%): 5 It takes 15 years for the investment to double Do you want to continue (yeso)? yes Enter the annual interest rate (%): 20 It takes 4 years for the investment to double. Do you want to continue (yeso)? yes Enter the annual interest rate (%): 10 It takes 8 years for the investment to double Do you want to continue (yeso)?no END OF THE SESSION GOOD BYE! PROBLEM 3: Write a program which repeatedly reads numbers until the user enters the word DONE. Once the word DONE is entered, print out the number of valid inputs the sum of all valid inputs the average of the valid inputs. If the user enters anything other than a number, detect their mistake using try and except and print an error message and skip to the next number. An example of output is the following: Enter a number: 4 Enter a number: 5 Enter a number: MLK Invalid input Enter a number: 7 Enter a number: done Total numbers of valid inputs: 3 Sum of valid inputs : 16 Average of valid inputs: 5.333333

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning Apache Cassandra Development

Authors: Vivek Mishra

1st Edition

1484201426, 9781484201428

More Books

Students also viewed these Databases questions

Question

3. Job rotation is used for all levels and types of employees.

Answered: 1 week ago