Ram

Lesson 8 of 19

Tuples & Sets

Choose collections for fixed values and unique values.

Introduction

Tuples are ordered collections that should not change. Sets hold unique values and make membership checks simple.

Pick a tuple for a fixed record and a set when duplicates should disappear.

Key insight

Choose collections for fixed values and unique values.

Example

coordinates = (27.7, 85.3)
tags = {"python", "web", "python"}
print(coordinates, tags)

This example shows the core tuples & sets idea in a small, runnable program.

Real-world example

Sets help remove duplicate tags from imported data.

Test yourself

2-question check

1

What is the main idea in Tuples & Sets?

2

Where can tuples & sets be useful?

Ready to check your understanding?

Answer every question, then submit your quiz.

Try it yourself

Python compiler

Runs in your browser. Nothing is sent to a server.

Output appears here

First run downloads the Python runtime, so it may take a moment.

Practice challenge

Create a set of three unique programming languages.

Previous
Next