{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "8666dc35",
   "metadata": {},
   "source": [
    "# 09-22 · Отладка логических ошибок\n",
    "\n",
    "Практика к разделу [«Отладка логических ошибок»](../../site/chapters/glava-09/09-22-otladka-logiki.html)."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8da0d8f8",
   "metadata": {},
   "source": [
    "## Цель\n",
    "\n",
    "Разложить сложное условие на части, чтобы найти причину неверного результата."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "596da14e",
   "metadata": {},
   "source": [
    "## Рабочий пример"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "68547916",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-16T17:23:12.328414Z",
     "iopub.status.busy": "2026-08-16T17:23:12.328220Z",
     "iopub.status.idle": "2026-08-16T17:23:12.345935Z",
     "shell.execute_reply": "2026-08-16T17:23:12.345388Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "age >= 18: True\n",
      "has_ticket: False\n",
      "eligible: False\n"
     ]
    }
   ],
   "source": [
    "age = 20\n",
    "has_ticket = False\n",
    "eligible = age >= 18 and has_ticket\n",
    "print(\"age >= 18:\", age >= 18)\n",
    "print(\"has_ticket:\", has_ticket)\n",
    "print(\"eligible:\", eligible)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4e714675",
   "metadata": {},
   "source": [
    "## Задание ★ Базовая практика\n",
    "\n",
    "Повторите разбор условия по частям — сохраните промежуточный результат age_ok отдельно от итогового eligible."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "0b52e618",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-16T17:23:12.346921Z",
     "iopub.status.busy": "2026-08-16T17:23:12.346805Z",
     "iopub.status.idle": "2026-08-16T17:23:12.349060Z",
     "shell.execute_reply": "2026-08-16T17:23:12.348719Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "True False\n"
     ]
    }
   ],
   "source": [
    "age = 20\n",
    "has_ticket = False\n",
    "age_ok = age >= 18\n",
    "eligible = age_ok and has_ticket\n",
    "print(age_ok, eligible)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Cartesian Python 3.14",
   "language": "python",
   "name": "cartesian-python314"
  },
  "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.14.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
