{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "6176697a",
   "metadata": {},
   "source": [
    "# 06-07 · Квадрат с помощью goto\n",
    "\n",
    "Практика к разделу [«Рисуем квадрат с помощью goto»](../../site/chapters/glava-06/06-07-goto-kvadrat.html)."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7a0f0519",
   "metadata": {},
   "source": [
    "## Цель\n",
    "\n",
    "Нарисовать фигуру через прямые координаты, а не движение и повороты."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9c9f7973",
   "metadata": {},
   "source": [
    "## Настройка (выполнить один раз)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "594ab47b",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:52:43.116384Z",
     "iopub.status.busy": "2026-08-14T20:52:43.116246Z",
     "iopub.status.idle": "2026-08-14T20:52:43.301346Z",
     "shell.execute_reply": "2026-08-14T20:52:43.300927Z"
    }
   },
   "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": "201a7a64",
   "metadata": {},
   "source": [
    "## Рабочий пример"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "5e79a79e",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:52:43.302562Z",
     "iopub.status.busy": "2026-08-14T20:52:43.302439Z",
     "iopub.status.idle": "2026-08-14T20:52:43.699804Z",
     "shell.execute_reply": "2026-08-14T20:52:43.699289Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Квадрат через goto готов.\n"
     ]
    }
   ],
   "source": [
    "artist.reset()\n",
    "artist.goto(100, 0)\n",
    "artist.goto(100, 100)\n",
    "artist.goto(0, 100)\n",
    "artist.goto(0, 0)\n",
    "print(\"Квадрат через goto готов.\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "59beeb80",
   "metadata": {},
   "source": [
    "## Эксперимент 1\n",
    "\n",
    "Нарисуйте треугольник тремя вызовами `goto()`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "979aef90",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:52:43.700914Z",
     "iopub.status.busy": "2026-08-14T20:52:43.700803Z",
     "iopub.status.idle": "2026-08-14T20:52:44.006632Z",
     "shell.execute_reply": "2026-08-14T20:52:44.005670Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Треугольник готов.\n"
     ]
    }
   ],
   "source": [
    "artist.reset()\n",
    "artist.goto(100, 0)\n",
    "artist.goto(50, 90)\n",
    "artist.goto(0, 0)\n",
    "print(\"Треугольник готов.\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "db3e57b1",
   "metadata": {},
   "source": [
    "## Задание ★ Базовая практика\n",
    "\n",
    "Нарисуйте прямоугольник (не квадрат — стороны разной длины) через `goto()`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "14fe3bb5",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:52:44.007953Z",
     "iopub.status.busy": "2026-08-14T20:52:44.007824Z",
     "iopub.status.idle": "2026-08-14T20:52:44.447848Z",
     "shell.execute_reply": "2026-08-14T20:52:44.447326Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Прямоугольник 150x80 готов.\n"
     ]
    }
   ],
   "source": [
    "artist.reset()\n",
    "artist.goto(150, 0)\n",
    "artist.goto(150, 80)\n",
    "artist.goto(0, 80)\n",
    "artist.goto(0, 0)\n",
    "print(\"Прямоугольник 150x80 готов.\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e1e1b078",
   "metadata": {},
   "source": [
    "## Завершение (выполнить один раз, в самом конце)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "f53a7075",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:52:44.448890Z",
     "iopub.status.busy": "2026-08-14T20:52:44.448779Z",
     "iopub.status.idle": "2026-08-14T20:52:44.452474Z",
     "shell.execute_reply": "2026-08-14T20:52:44.452004Z"
    }
   },
   "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
}
