Ask Question
10 January, 04:04

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

+2
Answers (1)
  1. 10 January, 04:48
    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?
Find 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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers