{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "990cca27",
   "metadata": {},
   "source": [
    "# 07-19 · clone()\n",
    "\n",
    "Практика к разделу [«clone() — копируем состояние»](../../site/chapters/glava-07/07-19-clone.html)."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d4639f9b",
   "metadata": {},
   "source": [
    "## Цель\n",
    "\n",
    "Создать клон черепашки и заставить его разойтись с оригиналом."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5d29e9de",
   "metadata": {},
   "source": [
    "## Настройка (выполнить один раз)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "99360f09",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-16T15:16:53.258432Z",
     "iopub.status.busy": "2026-08-16T15:16:53.258304Z",
     "iopub.status.idle": "2026-08-16T15:16:53.434599Z",
     "shell.execute_reply": "2026-08-16T15:16:53.434155Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Окно Turtle готово.\n"
     ]
    }
   ],
   "source": [
    "import turtle\n",
    "\n",
    "screen = turtle.Screen()\n",
    "artist = turtle.Turtle()\n",
    "artist.pensize(3)\n",
    "artist.pencolor(\"#5B24F9\")\n",
    "print(\"Окно Turtle готово.\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "928cee97",
   "metadata": {},
   "source": [
    "## Рабочий пример\n",
    "\n",
    "Клон, повёрнутый в другую сторону."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "f720e8d2",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-16T15:16:53.435736Z",
     "iopub.status.busy": "2026-08-16T15:16:53.435613Z",
     "iopub.status.idle": "2026-08-16T15:16:54.079644Z",
     "shell.execute_reply": "2026-08-16T15:16:54.079114Z"
    }
   },
   "outputs": [],
   "source": [
    "artist.reset()\n",
    "artist.penup(); artist.goto(0, -100); artist.pendown()\n",
    "artist.setheading(90)\n",
    "copy = artist.clone()\n",
    "copy.color(\"#DB2777\")\n",
    "artist.left(20); artist.forward(150)\n",
    "copy.right(20); copy.forward(150)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ff2aada9",
   "metadata": {},
   "source": [
    "## Задание ★ Базовая практика\n",
    "\n",
    "Создайте клон и разверните его на right(90) относительно оригинала, затем проведите обе черепашки вперёд на 100."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "993477d7",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-16T15:16:54.080943Z",
     "iopub.status.busy": "2026-08-16T15:16:54.080835Z",
     "iopub.status.idle": "2026-08-16T15:16:54.439977Z",
     "shell.execute_reply": "2026-08-16T15:16:54.439460Z"
    }
   },
   "outputs": [],
   "source": [
    "artist.reset()\n",
    "copy = artist.clone()\n",
    "copy.color(\"#059669\")\n",
    "copy.right(90)\n",
    "artist.forward(100)\n",
    "copy.forward(100)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0f9acd80",
   "metadata": {},
   "source": [
    "## Завершение (выполнить один раз, в самом конце)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "649e806f",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-16T15:16:54.441033Z",
     "iopub.status.busy": "2026-08-16T15:16:54.440926Z",
     "iopub.status.idle": "2026-08-16T15:16:54.443801Z",
     "shell.execute_reply": "2026-08-16T15:16:54.443375Z"
    }
   },
   "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
}
