Tuples
A tuple is a sequence of elements that cannot be modified. They are useful to group elements of different type.
t = ('bananas','200g',0.55)
In contrast to lists, tuples can also be used as keys in dictionaries.
Exercises
Exercise 1
Which are correct tuples?
- [ ]
(1, 2, 3) - [ ]
("Jack", "Knife") - [ ]
('blue', [0, 0, 255]) - [ ]
[1, "word"]
Exercise 2
What can you do with tuples?
- [ ]
group data of different kind - [ ]
change the values in them - [ ]
run a for loop over them - [ ]
sort them