Answer to Question #280253 in Python for kika

Question #280253

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.

# 2

def any_lowercase2(s):

   for c in s:

     if 'c'.islower():

        return 'True'

     else:

        return 'False'


1
Expert's answer
2021-12-20T10:01:43-0500

First. Returnes true only if the first letter in a string is lower.

In: any_lowercase1('Hello')
Out: False

Despite the string has lower symbols in it, function returnes False.


Second. Always returnes true.

In: any_lowercase2('HELLO')
Out: True 

Despite the string has no lower letters al all, function returnes True.


Third. Returnes true only in the last character is lower.

In: any_lowercase3('hELLO')
Out: False 

Despite the string has lower character in it, function returnes False.


Fourth. Correctly checks for lowercase letters in any position.


Fifth. Returnes true only if all symbols in the string are lower.

In: any_lowercase5('hELLO')
Out: False

The string contains lower letter, but function still returnes False, becourse it also contains upper ones.



Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS