Question: Python3 I have to use a docstring in every function. (1) OK or Not OK? (a) Write a function, checklen, that has two parameters, astring,

Python3

I have to use a docstring in every function.

(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 method, e.g., isupper.)

(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.)

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!