Ask Question
15 April, 22:32

This assignment is based on Exercise 8.4 from your textbook. Each of the following Python functions is supposed to check whether its argument has any lowercase letters.

For each function, describe what it actually does when called with a string argument. If it does not correctly check for lowercase letters, give an example argument that produces incorrect results, and describe why the result is incorrect.

def any_lowercase4 (s):

flag = False

for c in s:

flag = flag or c. islower ()

return flag

print (any_lowercase4 (s))

+4
Answers (1)
  1. 16 April, 02:16
    0
    The answer is "True".

    Explanation:

    Following are the correct code to this question, at which it will give "true" output:

    def any_lowercase4 (s) : #defining method any_lowercase4

    flag = False #defining flag variable and assign boolean value

    for c in s: #define loop that collect s variable value

    flag = flag or c. islower () # using flag variable that checks passes value in lower case

    return flag #return flag value

    s="Row Data" #assign string value in s variable

    print (any_lowercase4 (s)) #call method and prints its return value

    Output:

    True

    Program explanation:

    In this code a method "any_lowercase4" is defined, that accepts a variable s in its parameter, inside the method "flag" variable is used, that assign a value, that is false. In the next line, for loop is declared, inside the loop flag variable check parameter value into the lower case with or operator, and returns flag value. In the last line, inside the print method, the method "any_lowercase4" is called that accepts a string value.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “This assignment is based on Exercise 8.4 from your textbook. Each of the following Python functions is supposed to check whether its ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers