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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started