Code:
def printList( mylist ):
for l in mylist:
print("%d %d" % (mylist.index(l),l))
return
mylist = [10,20,30];
printList( mylist );
Output:

In python Write a function named printList to print the elements of a list with labels...
Python: Given a list named listOfThings, write a function that prints out if there are an odd number of things in the list or an even number of things in the list. If there is an even number of things, your function should print There is an even number of items in the list. If there is an odd number of things, your function should print There is an odd number of items in the list. Use the following function...
Using PYTHON: (Find the index of the smallest element) Write a function that returns the index of the smallest element in a list of integers. If the number of such elements is greater than 1, return the smallest index. Use the following header: def indexOfSmallestElement(lst): Write a test program that prompts the user to enter a list of numbers, invokes this function to return the index of the smallest element, and displays the index. PLEASE USE LISTS!
Python: P2 Write a function that reverses a python list using recursion (Chapter 6-3 in our textbook) E.g.: Input: [9, 8, 7, 6, 5, 4, 3, 2, 1, 0] Output: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] Constraints: - List elements are integers - The function should return a reversed array, not print its elements You may use the following code as template: def reverse(my_list, index = None): # your code here
(Python)Implement the function deep_list, which takes in a list, and returns a new list which contains only elements of the original list that are also lists. Use a list comprehension. def deep_list(seq): "" "Returns a new list containing elements of the original list that are lists. >>> seq = [49, 8, 2, 1, 102] >>> deep_list(seq) [] >>> seq = [[500], [30, 25, 24], 8, [0]] >>> deep_list(seq) [[500], [30, 25, 24], [0]] >>> seq = ["hello", [12, [25], 24],...
Python. Write a function swap_lists that takes in two lists and swap their elements in place. You can not use another list. You can not return lists. Input lists have the same size. def swap_lists(alist1, alist2): """Swaps content of two lists. Does not return anything. >>> list1 = [1, 2] >>> list2 = [3, 4] >>> swap_lists(list1, list2) >>> print(list1) [3, 4] >>> print(list2) [1, 2] >>> list1 = [4, 2, 6, 8, 90, 45] >>> list2 = [30, 41,...
PYTHON Given three unsorted lists, a name list (e.g. nameLst = [“Betty”, “Andrew”, “Zach”, “Cathy”, …]), an Exam1 score list (e.g. score1 = [50, 45, 48, 48, …]), and an Exam 2 score list (e.g. score2=[35, 48, 50, 37, …]) Write the following functions: def makeLst (aNameLst, e1ScoreLst, e2ScoreLst) : #the function will return a list of tuples as in the following form #[(“Betty”, (50,35)), (“Andrew”, (45,48)), (“Zach”, (48,50)), (“Cathy”, (48,37)), …] def personalAverage(aList) : #takes a class list in...
Python: Write a function named "sort_by_length" that takes a list/array of strings as a parameter and sorts the strings by their length
using python, Write a function named displayReverse that takes a list as a parameter and DISPLAYS the contents of the list to the screen in reverse. Submit the code and a screenshot of the program running in Linux
python Write a function named average_list() that uses a string list and outputs the av. len of all the strings in the list with also the amount of strings with a len of ^ average, below, and = to avg.
PYTHON 3 LANGUAGE , LINKED LISTS , define function ITERATIVELY Define an iterative function named alternate_i; it is passed two linked lists (ll1 and ll2) as arguments. It returns a reference to the front of a linked list that alternates the LNs from ll1 and ll2, starting with ll1; if either linked list becomes empty, the rest of the LNs come from the other linked list. So, all LNs in ll1 and ll2 appear in the returned result (in the...