Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons

© 2026 BraveProgrammer. All rights reserved.

  1. Courses
  2. /
  3. Python Fundamentals

Lesson 16 of 55 · Python

Data Structures – Sets

Duration: 20 minutes

Data Structures – Sets\n\nSets store unique, unordered items and support mathematical operations like union, intersection, and difference.\n\npython\nprimes = {2, 3, 5, 7}\nprimes.add(11)\nprimes.update([13, 17])\nprint('All primes:', primes)\n\n# Set operations\neven = {2, 4, 6, 8}\nprint('Intersection:', primes & even) # {2}\nprint('Union:', primes | even) # all unique numbers\n\n\nBecause sets discard duplicates automatically, they’re great for membership testing (x in my_set).\n

Previous: Data Structures – TuplesNext: Data Structures – Dictionaries