{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "title",
   "metadata": {},
   "source": [
    "# Functions\n",
    "\n",
    "Functions let you name a reusable block of code and call it whenever you need that behavior. This chapter covers how to define functions, pass information with parameters, return results, design readable functions, and understand recursion as a function that calls itself.\n",
    "\n",
    "- Functions reduce repetition by giving a name to a reusable process.\n",
    "- Parameters let a function work with different inputs.\n",
    "- Return values let a function produce a result for later code to use.\n",
    "- Scope controls where names are available.\n",
    "- Recursion solves a problem by reducing it to smaller versions of the same problem."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "video",
   "metadata": {},
   "source": [
    "<h2>Video</h2>\n",
    "\n",
    "This short overview introduces Python functions and the basic idea of defining reusable code with `def`.\n",
    "\n",
    "```{raw} html\n",
    "<iframe width=\"100%\" height=\"400\" src=\"https://www.youtube.com/embed/9Os0o3wzS_I\" title=\"Python Functions Tutorial\" frameborder=\"0\" allowfullscreen></iframe>\n",
    "```"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "goals",
   "metadata": {},
   "source": [
    "**Learning Goals**\n",
    "\n",
    "- Define and call custom functions with `def`\n",
    "- Use parameters, arguments, defaults, `*args`, and `**kwargs`\n",
    "- Use `return` statements to send results back to the caller\n",
    "- Explain local scope, function composition, docstrings, and basic lambda expressions\n",
    "- Trace recursive function calls using base cases and recursive cases"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "flow",
   "metadata": {},
   "source": [
    "<h2>Chapter Flow</h2>\n",
    "\n",
    "```{tableofcontents}\n",
    "```"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "glossary",
   "metadata": {},
   "source": [
    "<h2>Glossary</h2>\n",
    "\n",
    "| Term | Meaning |\n",
    "| --- | --- |\n",
    "| Function | A named, reusable block of code |\n",
    "| Parameter | A variable name listed in a function definition |\n",
    "| Argument | A value passed into a function call |\n",
    "| Return value | The result a function sends back to the caller |\n",
    "| Scope | The region of a program where a name can be used |\n",
    "| Docstring | A string that documents what a function does |\n",
    "| Lambda | A small anonymous function written as a single expression |\n",
    "| `*args` | Syntax that collects extra positional arguments into a tuple |\n",
    "| `**kwargs` | Syntax that collects extra keyword arguments into a dictionary |\n",
    "| Recursion | A pattern where a function calls itself |\n",
    "| Base case | The stopping condition in a recursive function |\n",
    "| Recursive case | The part of a recursive function that calls itself on a smaller problem |"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "name": "python"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
