Week 14 Notes
Notes from Student teaching
#Lists
- Lists are a sequence of variables, we can use them to store multiple items to one, collections of data, a d are changeable and allow for duplicates
- Tuple: collection that is ordered, unchangeable, allows duplicates
- Set: collection that is unordered, unchangeable, doesn’t allow duplicates
- Dictionary: collection that is ordered, changeable, doesn’t allow duplicates
Terms
- Index: a term used to sort data in order to reference to an element in a list (allows for duplicates)
-
Elements: the values in the list assigned to an index
-
Append(), adds data to end
-
Index() returns the index of the first element with specified value
-
Insert() adds a value into given position
-
Remove() removes the first item with specified value
-
Iteration saves time!
- Iteration is the repetition of a process or utterance applied to the result or taken from a previous statement.
-
There’s a lot of types of iteration though, what to use? How do we apply iteration to lists?
- Some methods include using a “for loop”, using a “for loop and range()”, using a “while loop”, and using comprehension