Member-only story

Complete Free Course on Python and Data Engineering

Zaid Alissa Almaliki
3 min readAug 3, 2024

--

There are four complex types in Python: Lists, Tuples, Sets and Dictionaries, let’s start talking about each one of them separately and giving practical examples.

Lists:

  1. Lists are mutable elements.
  2. Can have items of different types, strings, characters, integers, and floats all in the same list.
  3. Its index starts with zero.
  4. They are ordered and have duplicated elements. Its operations, append, remove and modify.

The code below is a practical example:

Tuples:

  1. Immutable data.
  2. Can be used as immutable lists. tuple = (1, 2, 3, 4, 5, "b", "c", "d")
  3. Can be used as a collection of fields, the number of elements is fixed, and the order is important. city, year, pop, chg, area = ('Tokyo', 2003, 32_450, 0.66, 8014)

The code below is a practical example:

Sets:

  1. Mutable data.
  2. Elements are not ordered, nor duplicated.
  3. Sets are hashable so…

--

--

Zaid Alissa Almaliki
Zaid Alissa Almaliki

Written by Zaid Alissa Almaliki

Data Engineer, LinkedIn and Twitter Top Voice. Contributing to leading platforms like Towards Data Science.

No responses yet