5
answers
0
watching
361
views
27 Jan 2018
Question 7. [11 MARKS] This question has you write the bodies of two functions. Complete each function according to its docstring. Part (a) [6 MARKS] Note: you will most likely not need all of the space on this page. def count_letter_case (L): "" (list of list of str) -> list of tuple of int Precondition: each str in L is non-empty and contains only alphabetic characters Count the number of words in each sublist of L that start with lowercase and uppercase letters. Return a new list where each element is a two-item tuple in which the first item is the number of words in the list at the corresponding index of L that start with a lowercase letter and the second item is the number of words in the list at the corresponding index of L that start with an uppercase letter. >>> count_letter_case([['apple', 'Banana'], ['PEAR'], [], ['PEACH', 'apRICot', 'plum']]) [(1, 1), (0, 1), (0, 0), (2, 1)]
Question 7. [11 MARKS] This question has you write the bodies of two functions. Complete each function according to its docstring. Part (a) [6 MARKS] Note: you will most likely not need all of the space on this page. def count_letter_case (L): "" (list of list of str) -> list of tuple of int Precondition: each str in L is non-empty and contains only alphabetic characters Count the number of words in each sublist of L that start with lowercase and uppercase letters. Return a new list where each element is a two-item tuple in which the first item is the number of words in the list at the corresponding index of L that start with a lowercase letter and the second item is the number of words in the list at the corresponding index of L that start with an uppercase letter. >>> count_letter_case([['apple', 'Banana'], ['PEAR'], [], ['PEACH', 'apRICot', 'plum']]) [(1, 1), (0, 1), (0, 0), (2, 1)]
28 Jun 2023
Already have an account? Log in
Beverley SmithLv2
30 Jan 2018
Already have an account? Log in