Python · live now

Tuples

Python's immutable sequence: writing tuple literals, indexing and slicing them as with lists, and why immutability does not reach the mutable objects stored inside.

No account needed to read a lesson · 30-day money-back guarantee

See the full learning path

4

lessons

19

practice questions

25

prerequisite lessons

See it taught

1 of the 4 lessons here is free to preview - the whole explanation and worked example, with no account and no email.

The editor you get

A still of the editor, not a live one

Python Editor

1 2
point = (3, 4, 5) print(point[0], point[1:])

Editor Output

1

Output:

3 (4, 5)

You write and run Python in the browser - nothing to install, no setup. Questions are marked on the values your code produces. The snippet here is an example of the kind of code you write.

The 4 lessons

The 4 lessons in this unit. Expand any one to see what it covers. Each unlocks when its own prerequisites are passed.

01

Tuples

6 questions

Understand what makes a tuple distinct from a list in Python and learn how to correctly create tuples of any size using literal values, including cases with no elements or only one element.

Covers

Tuple overview

Creating a tuple using literal values

02

Tuple indexing, length and slicing

4 questions

Learn how to access individual elements in a tuple using indexing, determine its length with len(), and retrieve subsets of elements through slicing, using the same syntax as with lists.

Covers

Tuple indexing, length and slicing

03

Tuple immutability

Preview

4 questions

Understand that while tuples in Python are immutable containers whose elements cannot be changed, added, or removed, the contents of mutable objects stored within a tuple can still be modified, which can lead to unexpected side effects.

Covers

Tuple immutability

Preview this lesson - no account needed

04

Activity: travel itinerary builder

5 questions

Develop a Python program that allows users to build, update and customise a travel itinerary by adding destinations, activities and planning short trips.

Covers

Create itinerary

Get destination and activity

Add activities

Understand tuple mutability

Plan short-trips

Where this unit sits in the curriculum

This unit is part of our Python Done Right learning path, which contains 100 lessons. Every one of them is drawn below.

The diagnostic test lets you skip any lesson you already know, including the ones in this unit.

Every dot is a lesson and every line a prerequisite. The 4 red dots are the lessons in Tuples; the 25 blue dots feeding into them are the lessons Tuples depends on; the 71 pale dots are the rest of the learning path, which come after Tuples or alongside it.TuplesFirst lessons on the left100 lessons

Hover any dot to name its lesson.

4 lessons in this unit

25 prerequisite lessons across the unit, counting every step back to the start

71 other lessons in the learning path - after this unit, or alongside it

Every dot is a lesson, every line a prerequisite. You can only start a lesson once you have mastered all of its prerequisites, so you are always building on solid foundations.

Start Tuples

One subscription covers every learning path, and you can test out of anything you already know.

One subscription covers every learning path · 30-day money-back guarantee

More in Data structures: Lists, Dictionaries, Sets