DEV Community

Onaolapo-11
Onaolapo-11

Posted on

When sets are created, duplicates of elements are eliminated

Day 73 [November 18, 2025]

I need to buckle down, as I'm still lagging on day day 3 & 4 goals, "Day 3-4: Control structures (if-else, loops)", as well as day 5 (and 6) goals, "Day 5-6: Functions and modules", and Day 7 target (exercises) (Meta AI, personal communication, August 8, 2025). If I haven't covered this, I can't make progress on day 8 - 72 goals.

Goals:
As extracted from the 'Python for Software Development' textbook by Halvorsen (n.d.):

  • Plotting in Python ✅
  • Subplots✅
  • Exercises✅
  • If ... Else
  • Arrays
  • For Loops
  • Nested
  • For Loops
  • While Loops
  • Exercises
  • Creating Functions in Python - Introduction
  • Functions with multiple return values
  • Exercises
  • Creating Classes in Python
  • The init () Function
  • Exercises
  • Creating Python Modules
  • Exercises

Notes:
Python for Data Science, AI & Development Course (IBM) (Santarcangelo, n.d.):
Module 2: Python Data Structures

  • Lists and Tuples
  • Dictionaries
  • Sets

Sets:

  • A kind of collection, but unordered (that is, element position is not noted) and they only have one type of a given element in a set (that is, when sets are created duplicates of elements are eliminated, only one type of that particular element is left) (see also LabEx, n.d.).
  • To covert a list to a set, we use the set() function
  • Set operations include: .add method (to add new element), .remove method (to remove an element), in command used to check if an item is in a set, etc.
  • To get the intersection of two sets we use the ampersand (&) sign: setBlue & setRed
  • Union of sets combines all elements of the individual sets: setBlue.union(setRed)
  • .issubset method finds use in ascertaining if a particular set's elements are completely in another: setBlue.issubset(setRed)

Summary:
When sets are created, duplicates of elements are eliminated.

References:

  1. Halvorsen, H. (n.d.). Python. https://halvorsen.blog/documents/programming/python/python.php#python4

  2. LabEx. (n.d.). How to use a python set for unique element operations. https://labex.io/tutorials/python-how-to-use-a-python-set-for-unique-element-operations-417976

  3. Santarcangelo, J. (n.d.). Python for data science, AI & development [MOOC]. Coursera. https://coursera.org/learn/python-for-applied-data-science-ai

Top comments (0)