The function swap_list_ends takes one parameter, L, which is a list. The function then swaps the first and last items in L and returns the object None.Β Notice that since L is mutable, the changes the function makes to L are visible back in the calling program.
Define the function make_uppercase(mylist), which takes a list parameter mylist (a list of strings), mutates the list by uppercasing each string in mylist. The function returns None.
Define the function square_nums_2 which takes a list of numbers, L, and mutates L so that each original item is now squared. For example, if L is [2, -5, 9] then, after calling square_nums_2(L), L == [4, 25, 81].
Define a function print_star_grid(rows, cols), which takes two positive integers as parameters and prints a rectangular grid of asterisks in response. rows indicates the number of rows to be printed, and cols indicates the number of columns (i.e., the length of each row).
6.Print Xβs and Oβs in a Grid with a Nested Loop.
Define a function print_XO_grid(rows, cols), which takes two positive integers as parameters and prints a rectangular grid of Xβs and Oβs in response. rows indicates the number of rows to be printed, and cols indicates the number of columns (i.e., the length of each row).
Define the function sum_nested(L), which takes parameter L (a list of lists of integers) and returns the sum of all the elements of all the inner lists of L.
The function gen_triples takes one parameter, L, a list of characters (i.e., strings of length one). The function returns a list of all possible 3-character strings that can be made from the characters in L.
The function add_entry takes a dictionary D and two additional parameters, new_key and new_val. The function adds new_key to the dictionary, using new_val for the value of D[new_key].
Hint: D.pop(k) is helpful here, but first you need to handle the case where k is not a key in D. You can search online to learn more, using search string: python dictionary delete item
The function has_key takes two parameters: D and k, where D is a dictionary and k is a possible key in D.Β The function returns True if k is a key in the dictionary D and False otherwise.
The function has_value takes two parameters: a dictionary D and a number num. The function returns True if num is a value in dictionary D; otherwise, it returns False.
The two lists are organized such that each item in key_list can be matched up with the item at the corresponding index in value_list to form a key-value pair for a dictionary.
For example, if key_list is ['a', 'b', 'c'] and value_listis ['yes', 'no', 'maybe'], then the new dictionary should contain these pairs: 'a':'yes', 'b':'no', 'c':'maybe'
TO DO: Accumulate D as explained in your textbook. Read up on how to generate a frequency table using a dictionary if the following hint leaves you puzzled.
The function get_mode(L) takes one parameter, L, a list of integers. get_mode builds a dictionary of frequencies to determine how often each number in the list occurs. Then it returns the mode of the list, that is, the number in L which occurs with the highest frequency.
Write a 6-line Python script (not a function definition). The purpose of the program is to read a positive integer n from standard input and then show how to "count by k" for k = 0, 1, 2, ..., n.