Py Tuples Sets — Free Python Tutorial

Learn Py Tuples Sets in Python with a free, beginner-friendly tutorial, examples and practice for Indian students on Syllab.in.

Py Tuples Sets — Free Python Tutorial

Learn Py Tuples Sets in Python with a free, beginner-friendly tutorial, examples and practice for Indian students on Syllab.in.

✓ 100% Free ✓ No Login Needed ✓ NCERT / CBSE Aligned ✓ Download as PDF

TL;DR: Learn Py Tuples Sets in Python with a free, beginner-friendly tutorial, examples and practice for Indian students on Syllab.in.

Written & reviewed by the Syllab.in Academic Team (CBSE/NCERT subject experts) · Updated

🤖 Stuck on any question? Ask Syllab's free AI Tutor for a step-by-step explanation — instant, unlimited, no login.

Py Tuples Sets in Python

Python has 4 main collection types: list (ordered, mutable), tuple (ordered, immutable), set (unordered, no duplicates), dict (key-value pairs). Choosing the right one matters for correctness and performance.

Tuple: Like a list but immutable (can't be changed after creation). Use tuples for data that shouldn't change: coordinates (x, y), RGB colours (255, 0, 0), database records. Tuples are faster than lists and can be used as dictionary keys.

Set: Unordered collection with NO duplicates. Automatically removes duplicates when you add elements. Excellent for: removing duplicates from a list, checking membership (in operator is O(1) — instant), set operations (union ∪, intersection ∩, difference −).

Py Tuples Sets — Syntax

# Tuple — immutable
point = (10, 20)
colours = ("red", "green", "blue")

# Set — no duplicates, unordered
unique_marks = {85, 72, 85, 91, 72}  # becomes {72, 85, 91}

# Set operations:
set_a | set_b   # union
set_a & set_b   # intersection
set_a - set_b   # difference

Learn Py Tuples Sets step by step with Syllab's free interactive Python tutorial — runnable code examples, practice exercises and instant AI feedback, all free with no signup. Explore the full Python course →