• Compound Data Type is a data made from collection of various data types like strings, integers, etc.
  • Compound Data Types in Python can be represented by List, Dictionary, Tuple, Set.
  • Tools I can use to work with Compound Data Types are Iterators, For loops, While loops, and other Functions

List

  • Using square brackets [ ]
  • The elements are separated by comma
  • Maintain order of the elements
  • Using index to access the elements
  • Mutable, the elements can be change

[1, 2, 3, 1, True, "Kei", "Mars", 0.5, None]

Dictionary

  • Using curly braces { }
  • No indexing
  • Maintain order of the elements
  • The elements are in key:value pair format
  • Using key to access the value
  • Key can be string or integer, but it has to be immutable data type

{"name":"Mars", "age":4, "color":"black", "hobby":"barking"}

Set

  • Using curly braces { }
  • The elements are separated by comma
  • No duplicate value allowed
  • No order, the position of the elements change each time
  • No indexing because Set doesn’t have order

{1, 2, 3, True, "Kei", "Mars", 0.5, None}

Tuple

  • Using parentheses ( )
  • Immutable, the elements can’t be change
  • Maintain order of the elements
  • Using index to acess the elements

(1, 2, 3, True, "Kei", "Mars", 0.5, None)