Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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.

# 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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning C# 5.0 Databases

Authors: Vidya Vrat Agarwal

2nd Edition

1430242604, 978-1430242604

Students also viewed these Databases questions