{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "b14df612",
   "metadata": {},
   "source": [
    "# 11-09 · Мини-проект — бесконечные цвета\n",
    "\n",
    "Практика к разделу [«Мини-проект — бесконечные цвета»](../../site/chapters/glava-11/11-09-mini-proekt-cveta.html)."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "804949e5",
   "metadata": {},
   "source": [
    "## Цель\n",
    "\n",
    "Словарь как карта соответствий + Turtle."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5cae3a7e",
   "metadata": {},
   "source": [
    "## Настройка (выполнить один раз)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "b1f4db29",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-17T14:45:20.262078Z",
     "iopub.status.busy": "2026-08-17T14:45:20.261967Z",
     "iopub.status.idle": "2026-08-17T14:45:20.429848Z",
     "shell.execute_reply": "2026-08-17T14:45:20.429379Z"
    }
   },
   "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": "10a7216c",
   "metadata": {},
   "source": [
    "## Рабочий пример"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "a25ee5e0",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-17T14:45:20.430878Z",
     "iopub.status.busy": "2026-08-17T14:45:20.430758Z",
     "iopub.status.idle": "2026-08-17T14:45:21.551160Z",
     "shell.execute_reply": "2026-08-17T14:45:21.550796Z"
    }
   },
   "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": "7ef80aa5",
   "metadata": {},
   "source": [
    "## Задание ★★ Самостоятельная задача\n",
    "\n",
    "Добавьте свои пары слово-цвет и нарисуйте фигуру для каждой."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "edd6be9b",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-17T14:45:21.552437Z",
     "iopub.status.busy": "2026-08-17T14:45:21.552331Z",
     "iopub.status.idle": "2026-08-17T14:45:25.452982Z",
     "shell.execute_reply": "2026-08-17T14:45:25.452479Z"
    }
   },
   "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": "ead36ce4",
   "metadata": {},
   "source": [
    "## Завершение (выполнить один раз, в самом конце)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "d59b7ffa",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-17T14:45:25.453937Z",
     "iopub.status.busy": "2026-08-17T14:45:25.453833Z",
     "iopub.status.idle": "2026-08-17T14:45:25.456713Z",
     "shell.execute_reply": "2026-08-17T14:45:25.456282Z"
    }
   },
   "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
}
