# Tutorial 2 - Problem 8 def any_lowercase1(s): """ This function only looks at the first letter in s returning True if it is lowercase, False otherwise. """ for c in s: if c.islower(): return True else: return False def any_lowercase2(s): """ This function always returns 'True' since hard-coded or literal value 'c' is a lowercase letter. """ for c in s: if 'c'.islower(): return 'True' else: return 'False' def any_lowercase3(s): """ This function returns True if the last letter is a lowercase or False if the last letter is an uppercase. """ for c in s: flag = c.islower( ) return flag def any_lowercase4(s): """ This function returns True if there is at least one lowercase letter in s, False otherwise. """ flag = False for c in s: flag = flag or c.islower( ) return flag def any_lowercase5(s): """ This function returns False at the first occurrence of an upper case letter in s, otherwise it continues to parse s until it has reached its last lowercase letter, then returns True. """ for c in s: if not c.islower(): return False return True # Main part of the program print('any_lowercase1("ABCEd")): ', any_lowercase1("ABCEd")) print('any_lowercase2("ABCEd")): ', any_lowercase2("ABCEd")) print('any_lowercase3("ABCEd")): ', any_lowercase3("ABCEd")) print('any_lowercase4("ABCEd")): ', any_lowercase4("ABCEd")) print('any_lowercase5("ABCEd")): ', any_lowercase5("ABCEd")) # What other test cases will you use to test these functions? # Challenge: can you modify the functions above such that they all have only one "return" statement?