Time: 10-15 minutes
Purpose: Give you practice with using lists and tuples in python.
Introduction: Try to work out the following tasks in python and run them to make sure they do what you expect.
Tasks:
- append 6 to the end of this list
list1 = [1,2,3,4,5]
- What is the index of the number 3 in list1?
- Sort this list
list2 = ['b','d','c','e','a']
- Use slicing to get [2,3,4] out of this list
list3 = [1,2,3,4,5]
- find the sum of all items in list 3. (Hint: look up sum() in the python documentation)
- what number is at index -1 in list3?
Further learning resources:
- https://www.programiz.com/python-programming/list
- https://www.tutorialspoint.com/python/python_lists.htm
- https://www.w3schools.com/python/python_tuples.asp
- https://www.tutorialspoint.com/python/python_tuples.htm
A file showing a possible solution is available on github here