PYTHON CORE · LESSON 28

Immutable group

Tuple · about 10 minutes

Learning with progressRead the summary for free. To save the work, log in to the account.
STEP 1

Looks like a list.

The tuple holds several values. It's written in parentheses.

point = (2, 3)
print(point)

✦ It will appear (2, 3).

STEP 2

When not to change

The elements of the tuple cannot be replaced after creation. The first element, like the list, is number 0.

point = (2, 3)
print(point[0])

✦ Answer 2.

IN-CLASS PRACTICE

Type the code yourself

Dial the tuple and get the first element.

point = (4, 7)
print(point[0])
Open the editor for class work
HOMEWORK

Solve it yourself

Create a coords tuple from the numbers 5 and 8. Remove the second element.

The answer is hidden. Use similar examples from the lesson notes.

Opening up your homework