Write a function that does each of the following:
Create an empty list and print it.
Create a list containing several strings and integers. Print it.
Append a value to one of these lists. Print it.
Insert a value at the beginning of one of these lists. Print it.
Print the length of the list.
Select (index) an element from one of your lists. Print it.
Select and print a slice from one of your lists.
Add two lists together. Print the result.
Add a list to this list using the augment operator (+=). Print it.
Sort the list. Print it.
Use the for: statement to print each item in one of your lists.
Create a tuple with one element. Print it.
Create a tuple with more than one element. Print it.
Write a function apply(fn, numbers) that takes a function and a list of numbers. apply should return a new list that contains the result of applying fn to each element of numbers.
Given a list data1 (with an even number of items), create a list of 2-tuples data2 where:
data2[i] = (data1[i] , data1[i+1])
For example, given this list:
data1 = ['aa', 11, 'bb', 22, 'cc', 33, 'dd', 44]
create this list:
data2 = [('aa', 11), ('bb', 22), ('cc', 33), ('dd', 44)]
Create a list of integers, some of which are odd and some of which are even. Sort this list using the sort method so that all the odd numbers are at the beginning. Hint: the sort method takes an additional, optional argument, a function cmp(a, b) which returns:
What you will learn: