1. Write a function called all_names() that takes a list of first names and a list of last names. This function generates and returns a list of all the first and last name combinations as a list of...

1. Write a function called all_names() that takes a list of first names and a list of last names. This function generates and returns a list of all the first and last name combinations as a list of strings. Signature: def all_names(f_names, l_names): # your code here Return name_list Assumptions: All the elements in the list are strings. (You cannot assume that the two lists are the same length.) Examples: firsts = ["Hanna", "Jaime", "Lynn"] lasts = ["Long", "Ming", "Caravalli"] more_firsts = ["Jose", "Roman", "Trevor", "Stephano"] all_names(firsts, lasts) → ["Hanna Long", "Hanna Ming", "Hanna Caravalli", "Jaime Long","Jaime Ming","Jaime Caravalli","Lynn Long", "Lynn Ming","Ming Caravallo"] all_names(more_firsts, lasts) → ["Jose Long","Jose Ming","Jose Caravalli","Roman Long","Roman Ming","Roman Caravalli", "Trevor Long","Trevor Ming","Trever Caravalli","Stephano Long","Stephano Ming","Stephano Caravalli"] 2. Write a function called count_names()that takes two lists of names. The first list is the first names of all the students in eighth grade at a middle school. The second list is the most common first names at the school. The function returns the total number of occurrences of the common names in the larger list. (HINT: You cannot use the in operator because you need to know how many times the name is in the bigger list.) Signature: def count_names(all_names, common_names): # your code here return count Assumptions: None. Examples: stus = ["Earl", "Cathy", "Petra", "Earl", "Jane", "Joan", "Jane", "Omar", "Earl", "Jane", Cathy", "Kendra", "Earl", "Beth", "Bari", "Hanna", "Cathy", "Earl", "Armando", "Horace", "Bert"] common_names = ["Earl", "Petra", "Jane"] common_names2 = ["Steven", "Horace"] count_names(stus, common_names) → 9 count_names(stus, common_names2) → 1 3. Write a function called make_full_names() that takes a list of names and generates a new list. The input to the function is a one-dimensional list of first and last names. The function generates a list of mini-lists in which each mini-list is the first and last names of each person. Signature: def make_full_names(names): # your code here return full_names Assumptions: The list of names has an even number of names. Example(s): make_full_names(['Mara', "Mooney', 'Lourdes', 'Luka', 'Sandra', 'Storie','Timo', 'Trotter', 'Aishu', 'Ashwini', 'Johan', 'Menon']) → [['Mara', "Mooney'], ['Lourdes', 'Luka'], ['Sandra', 'Storie'], ['Timo', 'Trotter'], ['Aishu', 'Ashwini'], ['Johan', 'Menon']] 4. Write a function called tall_enough() that takes a two lists and an integer. The first list is a list of names and the second list is of corresponding heights for each person in the first list. This function returns a list of the names of all the people whose height is greater than or equal to the height given. Signature: def tall_enough(names, heights, min_height): # your code here return tall_people Assumptions: The list of names and heights have the same length. Examples: tall_enough(["Rodrigo", "Jose", "Carlito", "Juan", "Mateo"], [62, 69, 71, 54, 59], 65) → ["Jose", "Carlito"] tall_enough(["Rena", "Jesse", "Carlotta", "Javiera", "Maria"], [61, 68, 63, 69, 58], 58) → ["Rena", "Jesse", "Carlotta", "Javiera", "Maria"] 5. Write a function called find_largest() that takes a two-dimensional list of numbers and returns largest number in the list. Signature: def find_largest(nums): # your code here return largest Assumptions: The list and its mini-lists can be of any size. All the numbers are positive. Examples: find_largest([1,1,1],[2,4,7,9.6],[5,100,-33,101],[66,0]])→ 101 find_largest([[], [], [33], [.03, 77.2]] → 77.2 6. Write a function called check_diagonals() that takes a two-dimensional list and returns True if all the elements along each diagonal are the same element. Otherwise, the function returns False. Signature: def check_diagonals(twoD_list): # your code here return Assumptions: The number of "rows" and "columns" are the same. That is, it's a square larger than 0x0 Examples: lst1 = [[1,0,1],[5,6,4],[1, 5, 1]] check_diagonals(lst1) → False lst2 = [['m', 'm', 'r', 'x', 'm'], ['u', 'm', 'c', 'm', 'q'], ['a', 'b', 'm', 'x', 'q'], ['t', 'm', 'c', 'm', 'q'], ['m', 'b', 'x', 'm', 'm']] check_diagonals(lst2) → Tru
Apr 10, 2023
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here