{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "bf4afb18",
   "metadata": {},
   "source": [
    "# 10-07 · Автоматическая мандала\n",
    "\n",
    "Практика к разделу [«Мини-проект — автоматически рисуем мандалу»](../../site/chapters/glava-10/10-07-avtomatiziruem-mandalu.html)."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1f8ef2ae",
   "metadata": {},
   "source": [
    "## Цель\n",
    "\n",
    "Переписать мандалу из главы 6 с for + range() вместо while."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "01afdbd3",
   "metadata": {},
   "source": [
    "## Настройка (выполнить один раз)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "ae9a0f10",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:54:07.078742Z",
     "iopub.status.busy": "2026-08-14T20:54:07.078599Z",
     "iopub.status.idle": "2026-08-14T20:54:07.254665Z",
     "shell.execute_reply": "2026-08-14T20:54:07.254178Z"
    }
   },
   "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": "cde0217b",
   "metadata": {},
   "source": [
    "## Рабочий пример"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "108b0a01",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:54:07.255655Z",
     "iopub.status.busy": "2026-08-14T20:54:07.255544Z",
     "iopub.status.idle": "2026-08-14T20:54:18.195189Z",
     "shell.execute_reply": "2026-08-14T20:54:18.194644Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Мандала готова, лучей: 36\n"
     ]
    }
   ],
   "source": [
    "artist.reset()\n",
    "shag_ugla = 10\n",
    "\n",
    "for ugol in range(0, 360, shag_ugla):\n",
    "    artist.setheading(ugol)\n",
    "    artist.forward(150)\n",
    "    artist.backward(150)\n",
    "\n",
    "print(\"Мандала готова, лучей:\", 360 // shag_ugla)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6abfc8a2",
   "metadata": {},
   "source": [
    "## Эксперимент 1\n",
    "\n",
    "Попробуйте разные значения shag_ugla: 5, 20, 45."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "93bf4c62",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:54:18.196324Z",
     "iopub.status.busy": "2026-08-14T20:54:18.196142Z",
     "iopub.status.idle": "2026-08-14T20:54:47.804213Z",
     "shell.execute_reply": "2026-08-14T20:54:47.803728Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "shag_ugla=5: лучей 72\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "shag_ugla=20: лучей 18\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "shag_ugla=45: лучей 8\n"
     ]
    }
   ],
   "source": [
    "for shag_ugla in [5, 20, 45]:\n",
    "    artist.reset()\n",
    "    for ugol in range(0, 360, shag_ugla):\n",
    "        artist.setheading(ugol)\n",
    "        artist.forward(150)\n",
    "        artist.backward(150)\n",
    "    print(f\"shag_ugla={shag_ugla}: лучей {360 // shag_ugla}\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d9cffcd5",
   "metadata": {},
   "source": [
    "## Завершение (выполнить один раз, в самом конце)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "c91cb8e5",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:54:47.805532Z",
     "iopub.status.busy": "2026-08-14T20:54:47.805378Z",
     "iopub.status.idle": "2026-08-14T20:54:47.810380Z",
     "shell.execute_reply": "2026-08-14T20:54:47.809694Z"
    }
   },
   "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
}
