TEST YOUR KNOWLEDGE: LISTS AND TUPLES
Lists and their contents are immutable, so their elements cannot be modified, added, or removed.
Lists and their contents are mutable, so their elements can be modified, added, or removed. A list is a data structure that helps store and manipulate an ordered collection of items.
What Python method adds an element to the end of a list?
Python’s append() method adds an element to the end of a list.
A data professional wants to instantiate a tuple. What Python elements can they use to do so? Select all that apply.
A data professional can use parentheses or the tuple() function to instantiate a tuple. A tuple is an immutable sequence that can contain elements of any data type.
What Python technique formulaically creates a new list based on the values in an existing list?
A list comprehension formulaically creates a new list based on the values in an existing list. A list comprehension functions like a for loop, but is a more efficient and elegant way to create a new list from an existing list.
Ready to test your recall?
Lists and their contents are immutable, so their elements cannot be modified, added, or removed.
How confident are you in this answer?