{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "05b18c29",
   "metadata": {},
   "source": [
    "# 10-01 · Циклы for\n",
    "\n",
    "Практика к разделу [«Волшебные циклы! Циклы for»](../../site/chapters/glava-10/10-01-cikly-for.html)."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "bf315d85",
   "metadata": {},
   "source": [
    "## Цель\n",
    "\n",
    "Освоить цикл for и range()."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f084cc26",
   "metadata": {},
   "source": [
    "## Рабочий пример"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "ec5e8454",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:53:57.332230Z",
     "iopub.status.busy": "2026-08-14T20:53:57.332051Z",
     "iopub.status.idle": "2026-08-14T20:53:57.349698Z",
     "shell.execute_reply": "2026-08-14T20:53:57.349149Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "1\n",
      "2\n",
      "3\n",
      "4\n"
     ]
    }
   ],
   "source": [
    "for i in range(5):\n",
    "    print(i)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4e7842d3",
   "metadata": {},
   "source": [
    "## Эксперимент 1 — range с началом и концом"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "407f68a9",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:53:57.352386Z",
     "iopub.status.busy": "2026-08-14T20:53:57.352048Z",
     "iopub.status.idle": "2026-08-14T20:53:57.355888Z",
     "shell.execute_reply": "2026-08-14T20:53:57.355181Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2\n",
      "3\n",
      "4\n",
      "5\n",
      "6\n",
      "7\n"
     ]
    }
   ],
   "source": [
    "for i in range(2, 8):\n",
    "    print(i)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f5072d09",
   "metadata": {},
   "source": [
    "## Эксперимент 2 — range с шагом"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "c45dd07f",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:53:57.357204Z",
     "iopub.status.busy": "2026-08-14T20:53:57.356974Z",
     "iopub.status.idle": "2026-08-14T20:53:57.360211Z",
     "shell.execute_reply": "2026-08-14T20:53:57.359610Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "2\n",
      "4\n",
      "6\n",
      "8\n"
     ]
    }
   ],
   "source": [
    "for i in range(0, 10, 2):\n",
    "    print(i)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b6a81ae9",
   "metadata": {},
   "source": [
    "## Задание ★ Базовая практика\n",
    "\n",
    "Выведите таблицу умножения числа 7 (7×1 до 7×10)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "e48d9432",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:53:57.361245Z",
     "iopub.status.busy": "2026-08-14T20:53:57.361124Z",
     "iopub.status.idle": "2026-08-14T20:53:57.363589Z",
     "shell.execute_reply": "2026-08-14T20:53:57.363100Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "7 x 1 = 7\n",
      "7 x 2 = 14\n",
      "7 x 3 = 21\n",
      "7 x 4 = 28\n",
      "7 x 5 = 35\n",
      "7 x 6 = 42\n",
      "7 x 7 = 49\n",
      "7 x 8 = 56\n",
      "7 x 9 = 63\n",
      "7 x 10 = 70\n"
     ]
    }
   ],
   "source": [
    "for i in range(1, 11):\n",
    "    print(f\"7 x {i} = {7 * i}\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b941d953",
   "metadata": {},
   "source": [
    "## Дополнительная задача ★★★\n",
    "\n",
    "Посчитайте сумму всех чисел от 1 до 100 циклом (без формулы)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "814be6a6",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:53:57.364490Z",
     "iopub.status.busy": "2026-08-14T20:53:57.364381Z",
     "iopub.status.idle": "2026-08-14T20:53:57.366520Z",
     "shell.execute_reply": "2026-08-14T20:53:57.366126Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "5050\n"
     ]
    }
   ],
   "source": [
    "total = 0\n",
    "for i in range(1, 101):\n",
    "    total += i\n",
    "print(total)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9f4b847c",
   "metadata": {},
   "source": [
    "## Проверка результата"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "93289498",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:53:57.367504Z",
     "iopub.status.busy": "2026-08-14T20:53:57.367397Z",
     "iopub.status.idle": "2026-08-14T20:53:57.369753Z",
     "shell.execute_reply": "2026-08-14T20:53:57.369288Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Верно: сумма чисел от 1 до 100 равна 5050.\n"
     ]
    }
   ],
   "source": [
    "assert sum(range(1, 101)) == 5050\n",
    "print(\"Верно: сумма чисел от 1 до 100 равна 5050.\")"
   ]
  }
 ],
 "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
}
