{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "10c3c94a",
   "metadata": {},
   "source": [
    "# 10-21 · break в Turtle\n",
    "\n",
    "Практика к разделу [«Спирали из дуг и итоги»](../../site/chapters/glava-10/10-08-spirali-itogi.html)."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1ad8bbb5",
   "metadata": {},
   "source": [
    "## Цель\n",
    "\n",
    "Остановить рисующий цикл раньше времени условием на положении черепашки."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "89028506",
   "metadata": {},
   "source": [
    "## Настройка (выполнить один раз)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "08d6c556",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-16T20:15:59.426078Z",
     "iopub.status.busy": "2026-08-16T20:15:59.425937Z",
     "iopub.status.idle": "2026-08-16T20:15:59.593499Z",
     "shell.execute_reply": "2026-08-16T20:15:59.592951Z"
    }
   },
   "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": "05fd470e",
   "metadata": {},
   "source": [
    "## Задание ★ Базовая практика"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "f4a1fcb0",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-16T20:15:59.594461Z",
     "iopub.status.busy": "2026-08-16T20:15:59.594348Z",
     "iopub.status.idle": "2026-08-16T20:16:12.621620Z",
     "shell.execute_reply": "2026-08-16T20:16:12.621028Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Остановлено на xcor = 153.99999999999955\n"
     ]
    }
   ],
   "source": [
    "artist.reset()\n",
    "dlina = 10\n",
    "\n",
    "for _ in range(50):\n",
    "    if artist.xcor() > 150:\n",
    "        break\n",
    "    artist.forward(dlina)\n",
    "    artist.left(90)\n",
    "    dlina += 6\n",
    "print(\"Остановлено на xcor =\", artist.xcor())"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "cea4cdb6",
   "metadata": {},
   "source": [
    "## Завершение (выполнить один раз, в самом конце)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "a6dd47f1",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-16T20:16:12.622608Z",
     "iopub.status.busy": "2026-08-16T20:16:12.622493Z",
     "iopub.status.idle": "2026-08-16T20:16:12.625853Z",
     "shell.execute_reply": "2026-08-16T20:16:12.625447Z"
    }
   },
   "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
}
