Question: Pay close attention to the return value for each function, as per the project specification. Programming style is important! Remember to Include a docstring in

Pay close attention to the return value for each function, as per the project specification. Programming style is important!

Remember to Include a docstring in every function per example in text (input variables and output variables, brief description of the function, examples of use) Use whitespace between operators and operands Use descriptive variable names Add appropriate comments.

(1) OK or Not OK?

(a) Write a function, checklen, that has two parameters, astring, of type string and le, an integer, that returns True if astring is le characters long, and False otherwise.

(b) Write a function, is_nonalnum, that takes one input parameter, astring, of type string and returns True if astring contains at least one non-alphanumeric character, and False otherwise. (HINT: Investigate string method isalnum.)

(c) Write a function, is_noEe, that takes one input parameter, astring, of type string and returns True if astring does NOT contain the characters 'E' or 'e', and False otherwise.

(d) Define a function, is_uc_alpha, with one parameter, astring, which returns True if any character in astring is an uppercase letter and returns False otherwise. (HINT: Look at each character in the string separately, using an appropriate string m

(e) Define a function, is_2numbers, with one parameter, astring, which returns True if astring has at least two numbers, and otherwise returns False. (HINT: Look at each character in the string separately, using an appropriate string method, e.g., isdigit).

(f) Define a function, is_special_char, with one parameter, astring, which returns True if astring contains any of the special characters, '!', '@', '#', '$', '%', '^', '&', and otherwise returns False. (HINT: Define a string variable which has the value of a string containing all of the special characters.)

(2) The countdownR(n) function is written using the technique called recursion, where a function calls itself. def countdownR(n): (int) Int the function, using if and else statement, counts down by 1 unit from n and prints the Blastoff!. countdownR(4) 4 3 2 1 Blastoff! if n == 0: print('Blastoff!') else: print(n) countdownrR(n - 1) # this is a recursion when you call the same function # in your function return None

(a) Convert the above function into countdownW(n) using a while loop.

(b) Convert the above function into countdownF(n) using a for loop.

(c) Edit the above function countdownR(n) to write recursive function countdownRby2(n), which also counts down from n and prints Blastoff! - but counts down by 2.

For example: >>> countdownRby2(7)

7

5

3

1

Blastoff!

(3) Write a function, savings, with two parameters, deposit and rate, that returns the number of years it will take for an initial deposit to a savings account to double, if it grows at rate (rate). Print the initial deposit and the amount in the savings account at the end of each year.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!