Datatypes and Data Structures recap

Datatypes recap

Let's recap by reviewing the different datatypes we have learned so far:

  • Integer: whole numbers, that is to say positive and negative numbers, including zero, without any decimal or fraction components.
    • Examples: 1, -2, 0
  • Float: real numbers with a fractional component. It's used to represent numbers that are not integers.
    • Examples: 1.0, -2.5, 0.0
  • Boolean: a binary in representing True and False, equivalently 1 and 0.
    • Examples: True, False
  • String: a sequence of alpha-numeric characters.
    • Examples: "Hello World", "123", "True"

Data structures recap

Let's conclude this section with a quick recap of data structures as well:

  • List: an ordered sequence of items, with its index starting at 0.
    • Examples: [1, 2, 3], ["a", "b", "c"]
  • Tuple: an immutable ordered collection of elements, with its index starting at 0.
    • Examples: (1, 2, 3), ("a", "b", "c")
  • Set: an unordered collection of unique elements; any duplicates are automatically removed upon creation or insertion.
    • Examples: {1, 2, 3}, {"a", "b", "c"}
  • Dictionary: a collection of unordered key-value pairs of elements, where keys are unique.
    • Examples: {1: "a", 2: "b", 3: "c"}, {"a": 1, "b": 2, "c": 3}