Skip to content

Latest commit

 

History

History
29 lines (17 loc) · 548 Bytes

tuples.md

File metadata and controls

29 lines (17 loc) · 548 Bytes

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