{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "ch06-title",
   "metadata": {},
   "source": [
    "# Sequences"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ch06-overview",
   "metadata": {},
   "source": [
    "This chapter presents Python's sequence types for storing values in order: lists and tuples. You will compare mutable and immutable sequences, and see how aliasing and copying affect programs that share lists, so you can choose the right structure for a task.\n",
    "\n",
    "- Creating and using lists and tuples\n",
    "- Accessing sequences with indexes and slices\n",
    "- Adding, removing, and transforming lists\n",
    "- Comparing mutability, identity, aliasing, and copying\n",
    "- Applying common sequence idioms used in everyday Python\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0600-video",
   "metadata": {},
   "source": [
    "<h2>Chapter Video</h2>\n",
    "\n",
    "This overview introduces Python's sequence containers, lists and tuples. Its last part covers sets, which Chapter 7 presents in detail.\n",
    "\n",
    "```{raw} html\n",
    "<iframe width=\"100%\" height=\"400\" src=\"https://www.youtube-nocookie.com/embed/W8KRzm-HUcc\" title=\"Python Tutorial for Beginners 4: Lists, Tuples, and Sets\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen referrerpolicy=\"strict-origin-when-cross-origin\"></iframe>\n",
    "```\n",
    "\n",
    "> *[Python Tutorial for Beginners 4: Lists, Tuples, and Sets (29:04)](https://youtube.com/watch?v=W8KRzm-HUcc) by Corey Schafer*\n",
    ">\n",
    "> Hosted on YouTube; property of its original creator, embedded here for educational reference only."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ch06-goals",
   "metadata": {},
   "source": [
    "<h2>Learning Objectives</h2>\n",
    "\n",
    "By the end of this chapter, you will be able to:\n",
    "\n",
    "1. Construct and manipulate Python lists using indexing, slicing, and core list methods\n",
    "2. Explain object identity, aliasing, shallow copies, and deep copies\n",
    "3. Predict how lists behave when passed to functions\n",
    "4. Use list comprehensions, unpacking, `enumerate()`, `zip()`, and sorting patterns\n",
    "5. Use tuples for fixed records, including tuple unpacking, returning multiple values from a function, packing arguments with `*args`, and named tuples\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ch06-flow",
   "metadata": {},
   "source": [
    "<h2>Chapter Flow</h2>\n",
    "\n",
    "```{container} chapter-flow\n",
    "1. {doc}`0601-lists`\n",
    "2. {doc}`0602-aliasing-copying`\n",
    "3. {doc}`0603-tuples`\n",
    "```"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ch06-glossary",
   "metadata": {},
   "source": [
    "<h2>Glossary</h2>\n",
    "\n",
    "| # | Term | Explanation |\n",
    "|---:|---|---|\n",
    "| 1 | Collection | An object that stores multiple values. |\n",
    "| 2 | Sequence | An ordered collection whose items can be accessed by position. |\n",
    "| 3 | List | An ordered, mutable sequence of values. |\n",
    "| 4 | Tuple | An ordered, immutable sequence of values. |\n",
    "| 5 | Mutability | Whether an object can be changed after it is created. |\n",
    "| 6 | Immutable | Describes an object whose contents cannot be changed after creation. |\n",
    "| 7 | Index | An integer position used to access an item in a sequence. |\n",
    "| 8 | Slice | A selected range of items from a sequence. |\n",
    "| 9 | List comprehension | A compact expression for building a list from an iterable. |\n",
    "| 10 | Nested list | A list that contains other lists as elements. |\n",
    "| 11 | Aliasing | Two or more names referring to the same object. |\n",
    "| 12 | Shallow copy | A copy of a collection that still shares nested objects with the original. |\n",
    "| 13 | Deep copy | A copy that recursively copies nested objects. |\n",
    "| 14 | Unpacking | Assigning items from a collection to separate names. |\n",
    "| 15 | `enumerate` | A built-in function that produces index-value pairs during iteration. |\n",
    "| 16 | `zip` | A built-in function that pairs items from multiple iterables. |\n",
    "| 17 | Identity | The property that distinguishes one object from another; `is` checks whether two names refer to the same object. |\n",
    "| 18 | Reference | The association between a variable and the object it refers to. |\n",
    "| 19 | Named tuple | A tuple whose fields can also be accessed by name, created with `namedtuple` from the `collections` module. |\n",
    "| 20 | Key function | A function passed as the `key` argument to `sorted`, `min`, or `max` that computes the value used to compare each item. |\n",
    "| 21 | Record | A group of related values that describe one thing, such as one sale or one student, often stored as a tuple. |\n",
    "| 22 | Argument packing (`*args`) | Collecting any number of extra positional arguments into a tuple through a parameter whose name begins with `*`. |\n",
    "| 23 | Equivalent | Describes two objects that have the same value, which `==` checks. |\n",
    "| 24 | Identical | Describes two names that refer to the same object, which `is` checks. |\n",
    "| 25 | Lexicographic comparison | Comparing two sequences element by element from the start, so the first pair of items that differ decides the result. |\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0600-slides",
   "metadata": {},
   "source": [
    "<h2><a href=\"overview.html\" target=\"_blank\" style=\"color: var(--pst-color-link, #176de8);\">Chapter Overview Slides</a></h2>"
   ]
  }
 ],
 "metadata": {
  "celltoolbar": "Tags",
  "kernelspec": {
   "display_name": ".venv",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.13.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
