{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "2e515eb2",
   "metadata": {},
   "source": [
    "# 10-04 · break и continue\n",
    "\n",
    "Практика к разделу [«Прервать миссию! break и continue»](../../site/chapters/glava-10/10-04-break-continue.html)."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "468b4fa5",
   "metadata": {},
   "source": [
    "## Цель\n",
    "\n",
    "Освоить break и continue."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "630b0cf1",
   "metadata": {},
   "source": [
    "## Рабочий пример — break"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "9e074255",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-16T20:12:46.002417Z",
     "iopub.status.busy": "2026-08-16T20:12:46.002309Z",
     "iopub.status.idle": "2026-08-16T20:12:46.025755Z",
     "shell.execute_reply": "2026-08-16T20:12:46.025254Z"
    }
   },
   "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": "4010c25e",
   "metadata": {},
   "source": [
    "## Эксперимент 1 — continue"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "1c46fa64",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-16T20:12:46.026680Z",
     "iopub.status.busy": "2026-08-16T20:12:46.026577Z",
     "iopub.status.idle": "2026-08-16T20:12:46.029080Z",
     "shell.execute_reply": "2026-08-16T20:12:46.028634Z"
    }
   },
   "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": "67d43893",
   "metadata": {},
   "source": [
    "## Задание ★ Базовая практика\n",
    "\n",
    "Найдите первое число от 1 до 100, которое делится и на 3, и на 7 — используя break."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "3e04b30c",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-16T20:12:46.030139Z",
     "iopub.status.busy": "2026-08-16T20:12:46.030027Z",
     "iopub.status.idle": "2026-08-16T20:12:46.032506Z",
     "shell.execute_reply": "2026-08-16T20:12:46.032059Z"
    }
   },
   "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": "d47e105a",
   "metadata": {},
   "source": [
    "## Проверка результата"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "41f0c2cd",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-16T20:12:46.033527Z",
     "iopub.status.busy": "2026-08-16T20:12:46.033415Z",
     "iopub.status.idle": "2026-08-16T20:12:46.035613Z",
     "shell.execute_reply": "2026-08-16T20:12:46.035196Z"
    }
   },
   "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
}
