{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "491d90b9",
   "metadata": {},
   "source": [
    "# 10-07 · Автоматическая мандала\n",
    "\n",
    "Практика к разделу [«Мини-проект — автоматически рисуем мандалу»](../../site/chapters/glava-10/10-07-avtomatiziruem-mandalu.html)."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4216f726",
   "metadata": {},
   "source": [
    "## Цель\n",
    "\n",
    "Переписать мандалу из главы 6 с for + range() вместо while."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "104ffe82",
   "metadata": {},
   "source": [
    "## Настройка (выполнить один раз)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "9d66f6be",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-16T20:13:56.068962Z",
     "iopub.status.busy": "2026-08-16T20:13:56.068829Z",
     "iopub.status.idle": "2026-08-16T20:13:56.243643Z",
     "shell.execute_reply": "2026-08-16T20:13:56.243083Z"
    }
   },
   "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": "2f89e620",
   "metadata": {},
   "source": [
    "## Рабочий пример"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "33d8327e",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-16T20:13:56.244901Z",
     "iopub.status.busy": "2026-08-16T20:13:56.244768Z",
     "iopub.status.idle": "2026-08-16T20:14:07.269124Z",
     "shell.execute_reply": "2026-08-16T20:14:07.268560Z"
    }
   },
   "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": "9a341be6",
   "metadata": {},
   "source": [
    "## Эксперимент 1\n",
    "\n",
    "Попробуйте разные значения shag_ugla: 5, 20, 45."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "752cc97d",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-16T20:14:07.270630Z",
     "iopub.status.busy": "2026-08-16T20:14:07.270453Z",
     "iopub.status.idle": "2026-08-16T20:14:37.133820Z",
     "shell.execute_reply": "2026-08-16T20:14:37.133263Z"
    }
   },
   "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": "73fa0959",
   "metadata": {},
   "source": [
    "## Завершение (выполнить один раз, в самом конце)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "f861b4f8",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-16T20:14:37.135347Z",
     "iopub.status.busy": "2026-08-16T20:14:37.135219Z",
     "iopub.status.idle": "2026-08-16T20:14:37.139219Z",
     "shell.execute_reply": "2026-08-16T20:14:37.138677Z"
    }
   },
   "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
}
