Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

use python IDLE when providing your solution and answer everything above 4. Compose a function display_even_forwards that accepts a single positive integer ( x )

image text in transcribed

use python IDLE when providing your solution and answer everything above

4. Compose a function display_even_forwards that accepts a single positive integer ( x ) as an argument, and prints all even integers on the interval [1,x) in ascending order, each on its own line. If the argument is not a positive integer, the function should print nothing (not even a blank line). For example, display_even_forwards (10) \# output (via print): \# 2 \# 4 #6 \# 8 display_even_forwards (-5) \# (no text should be displayed) 5. Compose a function num_yrs that accepts a single numerical argument: the initial deposit amount. This argument should be a positive floating point number. If the argument is zero or negative, the output of the function is undefined, but the function must return some result after a finite amount of time. If the argument is valid, then the function should return the number of years that would be required for the investment to grow to a total of at least $10,000, with an interest rate of 5% compounded annually. You should solve this problem using a loop to simulate the accrual of interest, stopping when the target amount has been exceeded. As a few examples, \( \begin{array}{ll}\text { num_yrs }(100) & \# \text { output: } 95 \\ \text { num_yrs }(150000) & \# \text { output: } 0 \\ \text { num_yrs }(-12) & \# \text { output: undefined (but must return *something*) } \\ \text { num_yrs }(0) & \# \text { output: undefined (but must return *something*) }\end{array} \)

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

Step: 3

blur-text-image

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

Introduction To Database And Knowledge Base Systems

Authors: S Krishna

1st Edition

9810206208, 978-9810206208

More Books

Students also viewed these Databases questions

Question

4. What does an expert do?

Answered: 1 week ago