5.32. Functions and Lists Write Code QuestionsΒΆ
Write a function called
average_of_num_listthat takes in a parameternum_listand returns the average of all the numbers in num_list. For example,average_of_num_list([0, 20.8, 80, 5])would return26.45.Write a function called
average_of_num_listthat takes in a parameternum_listand returns the average of all the numbers in num_list. For example,average_of_num_list([0, 20.8, 80, 5])would return26.45.-
Write a function called
namesthat takes in a parametername_listand returns an alphabetically sortedname_list. For example,names(['Susan', 'Sara', 'Sammy', 'Sarah'])would return['Sammy', 'Sara', 'Sarah', 'Susan']. Write a function called
remove_min_valuethat takes in a parameternum_listand returns anum_listwithout the minimum value fromnum_list. For example,remove_min_value([20, 4, 1203, 7482, 3])would return[20, 4, 1203, 7482].Write a function called
remove_min_valuethat takes in a parameternum_listand returns anum_listwithout the minimum value fromnum_list. For example,remove_min_value([20, 4, 1203, 7482, 3])would return[20, 4, 1203, 7482].-
Write a function called
range_given_listthat takes in a parameterlist_of_numsand returns the range (max value - min value) of the values. Try using the sort method and indexing. For examplerange_given_list([20, 100, 2000, 15, 3, 12])would return1997. Write a function called
remove_indices_after_first_max_valuethat takes in a parameternum_listand returns anew_num_listwith values up to the max value of the list. For example,remove_indices_after_first_max_value([200, 10, 5, 200])would return[5, 10, 5, 200].Write a function called
remove_indices_after_first_max_valuethat takes in a parameternum_listand returns anew_num_listwith values up to the max value of the list. For example,remove_indices_after_first_max_value([200, 10, 5, 200])would return[5, 10, 5, 200].-
Write a function called
transform_and_combinethat takes in two parameters,list_one, which must have at least one element, andlist_two. Remove the last element fromlist_one, then reverse the list. Sortlist_two, then extendlist_twowithlist_one, and returnlist_two. Hint: Use list methods (e.g., pop, sort, append, reverse, and extend). For example,transform_and_combine([5, 20, 3, 15, 200, 0, 17], ['Hello', 'Bye', 'How are you?'])would return['Bye', 'Hello', 'How are you?', 0, 200, 15, 3, 20, 5].