{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "496483e6",
   "metadata": {},
   "source": [
    "# 09-02 · Сравниваем и принимаем решение\n",
    "\n",
    "Практика к разделу [«Сравниваем и принимаем решение»](../../site/chapters/glava-09/09-02-sravnenie-i-reshenie.html)."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3fb9b487",
   "metadata": {},
   "source": [
    "## Цель\n",
    "\n",
    "Освоить все шесть операторов сравнения."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e9e44c72",
   "metadata": {},
   "source": [
    "## Рабочий пример"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "312d65b9",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:53:53.239855Z",
     "iopub.status.busy": "2026-08-14T20:53:53.239561Z",
     "iopub.status.idle": "2026-08-14T20:53:53.265963Z",
     "shell.execute_reply": "2026-08-14T20:53:53.265375Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "True\n",
      "True\n",
      "True False\n",
      "True False\n"
     ]
    }
   ],
   "source": [
    "print(5 == 5)\n",
    "print(5 != 3)\n",
    "print(5 > 3, 5 < 3)\n",
    "print(5 >= 5, 5 <= 3)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0d3f3bd3",
   "metadata": {},
   "source": [
    "## Типичная ошибка\n",
    "\n",
    "Путаница между `=` (присваивание) и `==` (сравнение)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "99473e77",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:53:53.267194Z",
     "iopub.status.busy": "2026-08-14T20:53:53.267064Z",
     "iopub.status.idle": "2026-08-14T20:53:53.270207Z",
     "shell.execute_reply": "2026-08-14T20:53:53.269630Z"
    },
    "tags": [
     "raises-exception"
    ]
   },
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "invalid syntax. Maybe you meant '==' or ':=' instead of '='? (638216577.py, line 2)",
     "output_type": "error",
     "traceback": [
      "  \u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[2]\u001b[39m\u001b[32m, line 2\u001b[39m\n\u001b[31m    \u001b[39m\u001b[31mif age = 20:\u001b[39m\n       ^\n\u001b[31mSyntaxError\u001b[39m\u001b[31m:\u001b[39m invalid syntax. Maybe you meant '==' or ':=' instead of '='?\n"
     ]
    }
   ],
   "source": [
    "age = 20\n",
    "if age = 20:\n",
    "    print(\"Совпадает\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c643c487",
   "metadata": {},
   "source": [
    "## Исправление"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "a4e35e2f",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:53:53.271424Z",
     "iopub.status.busy": "2026-08-14T20:53:53.271207Z",
     "iopub.status.idle": "2026-08-14T20:53:53.273947Z",
     "shell.execute_reply": "2026-08-14T20:53:53.273442Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Совпадает\n"
     ]
    }
   ],
   "source": [
    "age = 20\n",
    "if age == 20:\n",
    "    print(\"Совпадает\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "63cc8b31",
   "metadata": {},
   "source": [
    "## Задание ★ Базовая практика\n",
    "\n",
    "Сравните две строки по алфавиту."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "4644418b",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:53:53.275820Z",
     "iopub.status.busy": "2026-08-14T20:53:53.275633Z",
     "iopub.status.idle": "2026-08-14T20:53:53.278650Z",
     "shell.execute_reply": "2026-08-14T20:53:53.278181Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "True\n",
      "False\n"
     ]
    }
   ],
   "source": [
    "print(\"apple\" < \"banana\")\n",
    "print(\"Python\" == \"python\")"
   ]
  }
 ],
 "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
}
