{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "137305d8",
   "metadata": {},
   "source": [
    "# Control Flow"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c7097a69",
   "metadata": {},
   "source": [
    "This chapter covers the topics:\n",
    "- Introduction to Control Structures\n",
    "- Conditional Statements (if, elif, else)\n",
    "- Loops (for, while)\n",
    "- Control Flow Keywords (break, continue, pass)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8d5857fb",
   "metadata": {},
   "source": [
    "```{figure} ../../images/control-structures-sequence-selection-and-iteration.png\n",
    "---\n",
    "width: 80%\n",
    "name: control-structures-sequence-selection-and-iteration\n",
    "alt: Control structures sequence selection and iteration\n",
    "---\n",
    "[Control structures sequence selection and iteration](https://intro2c.sdds.ca/B-Computations/logic)\n",
    "```\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c6aae790",
   "metadata": {},
   "source": [
    "\n",
    "\n",
    "| Control Flow Statements Type | Control Flow Statement | Description |\n",
    "|---|---|---|\n",
    "| Conditional Statements | if-else | Executes a block of code if a specified condition is true, and another block if the condition is false. |\n",
    "|  | switch-case | Evaluates a variable or expression and executes code based on matching cases. |\n",
    "| Looping Statements | for | Executes a block of code a specified number of times, typically iterating over a range of values. |\n",
    "|  | while | Executes a block of code as long as a specified condition is true. |\n",
    "|  | do-while (`while True` in Python)| Executes a block of code once and then repeats the execution as long as a specified condition is true. |\n",
    "| Jump Statements | break | Terminates the loop or switch statement and transfers control to the statement immediately following the loop or switch. |\n",
    "|  | continue | Skips the current iteration of a loop and continues with the next iteration. |\n",
    "|  | return | Exits a function and returns a value to the caller. |\n",
    "|  | <span style=\"color: lightgrey\">goto</span> | Transfers control to a labeled statement within the same function. (Note: goto is generally discouraged due to its potential for creating unreadable and error-prone code.) |\n",
    "\n",
    "source: [geeksforgeeks](https://www.geeksforgeeks.org/computer-science-fundamentals/control-flow-statements-in-programming/)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2a8618b0",
   "metadata": {
    "editable": true,
    "slideshow": {
     "slide_type": ""
    },
    "tags": [
     "thebe-interactive"
    ]
   },
   "source": [
    "Is an inner function the same as `goto`?"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "71a8bdde-37ad-4155-b3f1-de47e4ca1f8f",
   "metadata": {
    "editable": true,
    "slideshow": {
     "slide_type": ""
    },
    "tags": [
     "hide-input"
    ]
   },
   "source": [
    "No. `goto` is one way to "
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "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
}
