1 Lists 3 Sets
NEXT MEETING
2
Tuples
NEXT MEETING
4 Dictionary
NEXT MEETING
❑ List – a collection that is ordered and changeable. Allows duplicate
members.
❑Tuple – a collection that is ordered and unchangeable. Allows
duplicate members.
❑Set – a collection that is unordered and unindexed.
❑Dictionary – a collection that is unordered, changeable, and indexed
- similar to arrays
- can contain any type of variable
- can contain as many variables as you wish
- can also be iterated
- a sequential collection of Python data values, where each value is
identified by an index
- values that make up a list are called its elements
- item in a list can be changed by accessing it directly as part of the
assignment statement
Enclose the elements in square brackets [ ]
numbers = [10, 20, 30, 40]
colors = [“red", “blue", “yellow"]
1. append() - is a list method that adds an element at the end of the list
2. insert() Inserts a new item at the position given
3. pop() Removes an element at the specified position and returns the
removed item
4. sort() Modifies a list to be sorted
5. reverse() Modifies a list to be in reverse order
6. remove() Removes an item with the specified value
7. clear() removes all the elements from the list
8. copy() returns a copy of the list
8. count() returns the number of elements with the specified value
9. extend() add the elements of a list to the end of the current list
10. index() returns the index of the first element with the specified value
11. len() returns the length of a list
12. max() returns largest element
13. min() returns the smallest element
14. sum() returns sum in the list
15. del statement removes an element from a list by using its position
16. in and not in are boolean operators that test membership in a sequence
17. split() method breaks a string into a list of words. By default, any number
of whitespace characters is considered a word boundary
18.join() method joins the list with the glue between each of the elements.
19. Glue - a separator string
20. list() turns value into a list