{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "ch08-title",
   "metadata": {},
   "source": [
    "# Dictionaries and Mapping"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ch08-overview",
   "metadata": {},
   "source": [
    "Dictionaries are mapping containers for fast lookup, record-like data, counting, grouping, and key-value relationships. Sets use the same hashing model to store unique values, test membership quickly, and combine groups with set algebra.\n",
    "\n",
    "- Dictionaries map keys to values\n",
    "- Keys must be hashable so Python can locate values efficiently\n",
    "- Dictionary methods support lookup, mutation, iteration, and transformation\n",
    "- Comprehensions build dictionaries from existing data\n",
    "- Lookup-heavy programs often depend on dictionary design\n",
    "- Sets store unique hashable values and support union, intersection, and difference\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ch08-video",
   "metadata": {},
   "source": [
    "<h2>Chapter Video</h2>\n",
    "\n",
    "<iframe width=\"100%\" height=\"400\" src=\"https://www.youtube-nocookie.com/embed/daefaLgNkw0\" title=\"Python Tutorial for Beginners 5: Dictionaries - Working with Key-Value Pairs\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen referrerpolicy=\"strict-origin-when-cross-origin\"></iframe>\n",
    "\n",
    "> *[Python Tutorial for Beginners 5: Dictionaries - Working with Key-Value Pairs (9:59)](https://youtube.com/watch?v=daefaLgNkw0) by Corey Schafer*\n",
    ">\n",
    "> Hosted on YouTube; property of its original creator, embedded here for educational reference only."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ch08-goals",
   "metadata": {},
   "source": [
    "<h2>Learning Objectives</h2>\n",
    "\n",
    "By the end of this chapter, you will be able to:\n",
    "\n",
    "1. Create, access, update, and delete entries in a Python dictionary\n",
    "2. Use dictionary methods such as `.get()`, `.keys()`, `.values()`, `.items()`, and `.update()`\n",
    "3. Write dictionary comprehensions and choose clear key-value structures\n",
    "4. Use dictionary patterns for counting, grouping, inversion, and sorted summaries\n",
    "5. Explain why dictionaries and sets depend on hashable values\n",
    "6. Use sets and frozensets for removing duplicates, fast membership tests, and set algebra\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ch08-flow",
   "metadata": {},
   "source": [
    "<h2>Chapter Flow</h2>\n",
    "\n",
    "```{container} chapter-flow\n",
    "1. {doc}`0701-dictionaries`\n",
    "2. {doc}`0702-dict-core-operations`\n",
    "3. {doc}`0703-dict-patterns`\n",
    "4. {doc}`0704-sets`\n",
    "```"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "dbc95da8",
   "metadata": {},
   "source": [
    "<h2>Glossary</h2>\n",
    "\n",
    "| # | Term | Explanation |\n",
    "|---:|---|---|\n",
    "| 1 | Dictionary | A mutable mapping that stores key-value pairs. |\n",
    "| 2 | Mapping | A collection that connects each key to a corresponding value. |\n",
    "| 3 | Key | The object used to look up a value in a dictionary. |\n",
    "| 4 | Value | The object stored under a key in a dictionary. |\n",
    "| 5 | Key-value pair | One association between a key and its value. |\n",
    "| 6 | Hashable | Describes an object whose hash value is stable, so it can be used as a dictionary key or a set element. |\n",
    "| 7 | Lookup | Retrieving a value by using its key. |\n",
    "| 8 | Membership testing | Checking whether a key is present in a dictionary. |\n",
    "| 9 | Adding/updating | Changing a dictionary by adding a new key-value pair or overwriting an existing value. |\n",
    "| 10 | Delete items | Removing key-value pairs from a dictionary when they are no longer needed. |\n",
    "| 11 | Common dictionary operations | Repeated dictionary tasks such as reading, adding, updating, deleting, and iterating. |\n",
    "| 12 | `get` | A dictionary method that retrieves a value and can return a default when the key is missing. |\n",
    "| 13 | `items` | A dictionary method that provides key-value pairs for iteration. |\n",
    "| 14 | Dictionary comprehension | A compact expression for building a dictionary from an iterable. |\n",
    "| 15 | `value_counts` | A counting function that returns how many times each value appears. |\n",
    "| 16 | `Counter` | A `dict` subclass from `collections` designed for counting hashable values. |\n",
    "| 17 | `defaultdict` | A `dict` subclass from `collections` that creates default values for missing keys. |\n",
    "| 18 | Inverting a dictionary | Building a new dictionary that swaps the role of keys and values. |\n",
    "| 19 | Sorting by value | Ordering dictionary entries using their values rather than their keys. |\n",
    "| 20 | Tuple key | A tuple used as a compound dictionary key. |\n",
    "| 21 | Set | An unordered, mutable collection of unique hashable values. |\n",
    "| 22 | Frozenset | An immutable version of a set; it is hashable, so it can be a dictionary key or a set element. |\n",
    "| 23 | Set operation | An operation such as union, intersection, difference, or symmetric difference. |\n",
    "| 24 | Nested dictionary | A dictionary stored as a value inside another dictionary, often used for records and JSON data. |\n",
    "| 25 | Hash table | The data structure that dictionaries and sets use to store items so that lookup takes about the same time no matter how many items there are. |\n",
    "| 26 | Hash value | An integer computed by `hash()` from an object and used to locate that object in a hash table. |\n",
    "| 27 | Accumulator | A variable that collects or accumulates data during a computation, such as a list built up inside a loop. |\n",
    "| 28 | Filtering | Looping through a collection and keeping only the items that satisfy a condition. |\n",
    "| 29 | Set comprehension | A compact expression in curly braces that builds a set from an iterable, discarding duplicates automatically. |\n",
    "| 30 | Big O notation | A way of describing how the time or memory an operation needs grows with the size of the data, such as O(1) or O(n). |\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0800-slides",
   "metadata": {},
   "source": [
    "<h2><a href=\"overview.html\" target=\"_blank\" style=\"color: var(--pst-color-link, #176de8);\">Chapter Overview Slides</a></h2>"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
