{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "616072f8",
   "metadata": {},
   "source": [
    "# 12-04 · Спирали!\n",
    "\n",
    "Практика к разделу [«Проект 12-4»](../../site/chapters/glava-12/12-04-spirali.html)."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0f2208d1",
   "metadata": {},
   "source": [
    "## Цель\n",
    "\n",
    "Нарисовать все пять вариантов спирали."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "af7eda5d",
   "metadata": {},
   "source": [
    "## Настройка (выполнить один раз)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "e8933a35",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:56:07.067852Z",
     "iopub.status.busy": "2026-08-14T20:56:07.067670Z",
     "iopub.status.idle": "2026-08-14T20:56:07.247887Z",
     "shell.execute_reply": "2026-08-14T20:56:07.247429Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Окно Turtle готово.\n"
     ]
    }
   ],
   "source": [
    "import turtle\n",
    "\n",
    "screen = turtle.Screen()\n",
    "artist = turtle.Turtle()\n",
    "artist.speed(0)\n",
    "print(\"Окно Turtle готово.\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "34bbc76d",
   "metadata": {},
   "source": [
    "## Квадратная спираль"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "f0f85e26",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:56:07.249108Z",
     "iopub.status.busy": "2026-08-14T20:56:07.248992Z",
     "iopub.status.idle": "2026-08-14T20:56:19.916744Z",
     "shell.execute_reply": "2026-08-14T20:56:19.916179Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Квадратная спираль готова.\n"
     ]
    }
   ],
   "source": [
    "artist.reset()\n",
    "dlina = 5\n",
    "for _ in range(60):\n",
    "    artist.forward(dlina)\n",
    "    artist.right(90)\n",
    "    dlina += 3\n",
    "print(\"Квадратная спираль готова.\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "82753773",
   "metadata": {},
   "source": [
    "## Случайная спираль"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "83594a22",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:56:19.917866Z",
     "iopub.status.busy": "2026-08-14T20:56:19.917744Z",
     "iopub.status.idle": "2026-08-14T20:56:32.362156Z",
     "shell.execute_reply": "2026-08-14T20:56:32.361720Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Случайная спираль готова.\n"
     ]
    }
   ],
   "source": [
    "import random\n",
    "\n",
    "artist.reset()\n",
    "dlina = 5\n",
    "for _ in range(60):\n",
    "    artist.forward(dlina)\n",
    "    artist.right(random.randint(80, 100))\n",
    "    dlina += 3\n",
    "print(\"Случайная спираль готова.\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "676766c5",
   "metadata": {},
   "source": [
    "## Треугольная спираль"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "34236a20",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:56:32.363232Z",
     "iopub.status.busy": "2026-08-14T20:56:32.363124Z",
     "iopub.status.idle": "2026-08-14T20:56:46.950432Z",
     "shell.execute_reply": "2026-08-14T20:56:46.950012Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Треугольная спираль готова.\n"
     ]
    }
   ],
   "source": [
    "artist.reset()\n",
    "dlina = 5\n",
    "for _ in range(60):\n",
    "    artist.forward(dlina)\n",
    "    artist.right(120)\n",
    "    dlina += 3\n",
    "print(\"Треугольная спираль готова.\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e7163456",
   "metadata": {},
   "source": [
    "## Звёздная спираль"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "9b82cbda",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:56:46.951468Z",
     "iopub.status.busy": "2026-08-14T20:56:46.951345Z",
     "iopub.status.idle": "2026-08-14T20:57:15.458197Z",
     "shell.execute_reply": "2026-08-14T20:57:15.457739Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Звёздная спираль готова.\n"
     ]
    }
   ],
   "source": [
    "artist.reset()\n",
    "dlina = 5\n",
    "for _ in range(100):\n",
    "    artist.forward(dlina)\n",
    "    artist.right(144)\n",
    "    dlina += 2\n",
    "print(\"Звёздная спираль готова.\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "00877988",
   "metadata": {},
   "source": [
    "## Круговая спираль"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "348e8950",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:57:15.459237Z",
     "iopub.status.busy": "2026-08-14T20:57:15.459051Z",
     "iopub.status.idle": "2026-08-14T20:57:41.620654Z",
     "shell.execute_reply": "2026-08-14T20:57:41.620148Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Круговая спираль готова.\n"
     ]
    }
   ],
   "source": [
    "artist.reset()\n",
    "radius = 5\n",
    "for _ in range(60):\n",
    "    artist.circle(radius, 90)\n",
    "    radius += 3\n",
    "print(\"Круговая спираль готова.\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "78410016",
   "metadata": {},
   "source": [
    "## Завершение (выполнить один раз, в самом конце)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "af1f9c31",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:57:41.621629Z",
     "iopub.status.busy": "2026-08-14T20:57:41.621515Z",
     "iopub.status.idle": "2026-08-14T20:57:41.624767Z",
     "shell.execute_reply": "2026-08-14T20:57:41.624364Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Окно Turtle закрыто.\n"
     ]
    }
   ],
   "source": [
    "screen.bye()\n",
    "print(\"Окно Turtle закрыто.\")"
   ]
  }
 ],
 "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
}
