{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "f1a7f939",
   "metadata": {},
   "source": [
    "# 11-09 · Мини-проект — бесконечные цвета\n",
    "\n",
    "Практика к разделу [«Мини-проект — бесконечные цвета»](../../site/chapters/glava-11/11-09-mini-proekt-cveta.html)."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "84d04985",
   "metadata": {},
   "source": [
    "## Цель\n",
    "\n",
    "Словарь как карта соответствий + Turtle."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ebd4b818",
   "metadata": {},
   "source": [
    "## Настройка (выполнить один раз)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "ee815f14",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:55:48.110841Z",
     "iopub.status.busy": "2026-08-14T20:55:48.110541Z",
     "iopub.status.idle": "2026-08-14T20:55:48.291987Z",
     "shell.execute_reply": "2026-08-14T20:55:48.291385Z"
    }
   },
   "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": "06b4f4e3",
   "metadata": {},
   "source": [
    "## Рабочий пример"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "ddaf4f46",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:55:48.293796Z",
     "iopub.status.busy": "2026-08-14T20:55:48.293649Z",
     "iopub.status.idle": "2026-08-14T20:55:49.411717Z",
     "shell.execute_reply": "2026-08-14T20:55:49.411196Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Нарисовано цветом: blue\n"
     ]
    }
   ],
   "source": [
    "artist.reset()\n",
    "cvetovaya_karta = {\"огонь\": \"red\", \"трава\": \"green\", \"небо\": \"blue\"}\n",
    "\n",
    "zapros = \"небо\"\n",
    "artist.pencolor(cvetovaya_karta[zapros])\n",
    "artist.circle(50)\n",
    "print(\"Нарисовано цветом:\", cvetovaya_karta[zapros])"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "fbfaeac3",
   "metadata": {},
   "source": [
    "## Задание ★★ Самостоятельная задача\n",
    "\n",
    "Добавьте свои пары слово-цвет и нарисуйте фигуру для каждой."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "783946fe",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:55:49.412757Z",
     "iopub.status.busy": "2026-08-14T20:55:49.412638Z",
     "iopub.status.idle": "2026-08-14T20:55:53.290193Z",
     "shell.execute_reply": "2026-08-14T20:55:53.289673Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Нарисовано 5 кругов.\n"
     ]
    }
   ],
   "source": [
    "artist.reset()\n",
    "cvetovaya_karta = {\n",
    "    \"огонь\": \"red\", \"трава\": \"green\", \"небо\": \"blue\",\n",
    "    \"солнце\": \"yellow\", \"ночь\": \"purple\",\n",
    "}\n",
    "\n",
    "artist.penup()\n",
    "for i, (slovo, cvet) in enumerate(cvetovaya_karta.items()):\n",
    "    artist.goto(i * 60 - 120, 0)\n",
    "    artist.pendown()\n",
    "    artist.pencolor(cvet)\n",
    "    artist.circle(20)\n",
    "    artist.penup()\n",
    "\n",
    "print(\"Нарисовано\", len(cvetovaya_karta), \"кругов.\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "78eb03fa",
   "metadata": {},
   "source": [
    "## Завершение (выполнить один раз, в самом конце)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "2da97f4f",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:55:53.291303Z",
     "iopub.status.busy": "2026-08-14T20:55:53.291093Z",
     "iopub.status.idle": "2026-08-14T20:55:53.295093Z",
     "shell.execute_reply": "2026-08-14T20:55:53.294598Z"
    }
   },
   "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
}
