Answer to Question #100462 in Python for oladepo

Question #100462
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.

# 1

def any_lowercase1(s):

for c in s:

if c.islower():

return True

else:

return False

# 2

def any_lowercase2(s):

for c in s:

if 'c'.islower():

return 'True'

else:

return 'False'

# 3

def any_lowercase3(s):

for c in s:

flag = c.islower()

return flag

# 4

def any_lowercase4(s):

flag = False

for c in s:
flag = flag or c.islower()

return flag

# 5

def any_lowercase5(s):

for c in s:

if not c.islower():

return False

return True
1
Expert's answer
2019-12-16T14:47:56-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

Praise
02.03.21, 11:58

This answer really helped me and left me awed

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS