{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "6814ae1c",
   "metadata": {},
   "source": [
    "# 10-04 · break и continue\n",
    "\n",
    "Практика к разделу [«Прервать миссию! break и continue»](../../site/chapters/glava-10/10-04-break-continue.html)."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4b79a6ec",
   "metadata": {},
   "source": [
    "## Цель\n",
    "\n",
    "Освоить break и continue."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a55843d3",
   "metadata": {},
   "source": [
    "## Рабочий пример — break"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "b25a156e",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:53:59.843726Z",
     "iopub.status.busy": "2026-08-14T20:53:59.843618Z",
     "iopub.status.idle": "2026-08-14T20:53:59.861425Z",
     "shell.execute_reply": "2026-08-14T20:53:59.860984Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n",
      "2\n",
      "3\n",
      "4\n"
     ]
    }
   ],
   "source": [
    "for number in range(1, 100):\n",
    "    if number == 5:\n",
    "        break\n",
    "    print(number)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1573926c",
   "metadata": {},
   "source": [
    "## Эксперимент 1 — continue"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "851514eb",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:53:59.862512Z",
     "iopub.status.busy": "2026-08-14T20:53:59.862394Z",
     "iopub.status.idle": "2026-08-14T20:53:59.864817Z",
     "shell.execute_reply": "2026-08-14T20:53:59.864402Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n",
      "2\n",
      "4\n",
      "5\n"
     ]
    }
   ],
   "source": [
    "for number in range(1, 6):\n",
    "    if number == 3:\n",
    "        continue\n",
    "    print(number)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "822003d3",
   "metadata": {},
   "source": [
    "## Задание ★ Базовая практика\n",
    "\n",
    "Найдите первое число от 1 до 100, которое делится и на 3, и на 7 — используя break."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "751685d8",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:53:59.865843Z",
     "iopub.status.busy": "2026-08-14T20:53:59.865738Z",
     "iopub.status.idle": "2026-08-14T20:53:59.868100Z",
     "shell.execute_reply": "2026-08-14T20:53:59.867662Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Нашли: 21\n"
     ]
    }
   ],
   "source": [
    "for number in range(1, 101):\n",
    "    if number % 3 == 0 and number % 7 == 0:\n",
    "        print(\"Нашли:\", number)\n",
    "        break"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ec6bdf62",
   "metadata": {},
   "source": [
    "## Проверка результата"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "a39491c8",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:53:59.869248Z",
     "iopub.status.busy": "2026-08-14T20:53:59.869132Z",
     "iopub.status.idle": "2026-08-14T20:53:59.871632Z",
     "shell.execute_reply": "2026-08-14T20:53:59.871078Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Верно: 21 — первое число, делящееся и на 3, и на 7.\n"
     ]
    }
   ],
   "source": [
    "assert 21 % 3 == 0 and 21 % 7 == 0\n",
    "print(\"Верно: 21 — первое число, делящееся и на 3, и на 7.\")"
   ]
  }
 ],
 "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
}
