M03 - Tuples Flashcards
1
Q
Tuples
A
- Similar to lists, but cannot be changed
- This means tuples are immutable: we cannot add or remove items from them
2
Q
Create empty tuple syntax
A
tuple_variable = ( )
or
tuple_variable = tuple( )
3
Q
Tuple syntax
A
tuple_variable = (‘Item1’ , ‘Item2’ , ‘Item3’ , etc.)
4
Q
Get tuple length syntax
A
len(tuple_variable)
5
Q
Tuples and indexing/slicing
A
Just like w/ lists:
tuple_variable[index]