{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "3a710a8d",
   "metadata": {},
   "source": [
    "# 19-02 · Экран и переменные\n",
    "\n",
    "Практика к разделу [«Настраиваем экран Turtle и переменные»](../../site/chapters/glava-19/19-02-ekran-peremennye.html)."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3f3f19ac",
   "metadata": {},
   "source": [
    "## Цель\n",
    "\n",
    "Настроить экран с tracer(0) и завести переменные состояния."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b2841ba4",
   "metadata": {},
   "source": [
    "## Настройка (выполнить один раз)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "c232f7b5",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:59:15.702440Z",
     "iopub.status.busy": "2026-08-14T20:59:15.702307Z",
     "iopub.status.idle": "2026-08-14T20:59:15.863957Z",
     "shell.execute_reply": "2026-08-14T20:59:15.863438Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Экран готов.\n"
     ]
    }
   ],
   "source": [
    "import turtle\n",
    "\n",
    "RAZMER_SHAGA = 20\n",
    "GRANICA = 280\n",
    "\n",
    "screen = turtle.Screen()\n",
    "screen.title(\"Змейка\")\n",
    "screen.bgcolor(\"black\")\n",
    "screen.setup(width=600, height=600)\n",
    "screen.tracer(0)\n",
    "print(\"Экран готов.\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "59db12d7",
   "metadata": {},
   "source": [
    "## Рабочий пример"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "e0c42e5b",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:59:15.864942Z",
     "iopub.status.busy": "2026-08-14T20:59:15.864826Z",
     "iopub.status.idle": "2026-08-14T20:59:15.867450Z",
     "shell.execute_reply": "2026-08-14T20:59:15.866972Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Направление: stop\n",
      "Счёт: 0\n",
      "Игра окончена: False\n"
     ]
    }
   ],
   "source": [
    "napravlenie = \"stop\"\n",
    "schet = 0\n",
    "igra_okonchena = False\n",
    "segmenty = []\n",
    "\n",
    "print(\"Направление:\", napravlenie)\n",
    "print(\"Счёт:\", schet)\n",
    "print(\"Игра окончена:\", igra_okonchena)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2815fe68",
   "metadata": {},
   "source": [
    "## Завершение (выполнить один раз, в самом конце)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "be361303",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:59:15.868355Z",
     "iopub.status.busy": "2026-08-14T20:59:15.868253Z",
     "iopub.status.idle": "2026-08-14T20:59:15.871446Z",
     "shell.execute_reply": "2026-08-14T20:59:15.870955Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Окно закрыто.\n"
     ]
    }
   ],
   "source": [
    "screen.bye()\n",
    "print(\"Окно закрыто.\")"
   ]
  }
 ],
 "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
}
