{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "3042c3b3",
   "metadata": {},
   "source": [
    "# 05-07 · Деление с остатком\n",
    "\n",
    "Практика к разделу [«Деление с остатком»](../../site/chapters/glava-05/05-07-delenie-s-ostatkom.html)."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d7c8088e",
   "metadata": {},
   "source": [
    "## Цель\n",
    "\n",
    "Освоить //, % и divmod() на реальных задачах группировки."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2a47e9b7",
   "metadata": {},
   "source": [
    "## Рабочий пример"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "05fa1459",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-16T12:02:48.722581Z",
     "iopub.status.busy": "2026-08-16T12:02:48.722320Z",
     "iopub.status.idle": "2026-08-16T12:02:48.741965Z",
     "shell.execute_reply": "2026-08-16T12:02:48.741255Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "3\n",
      "2\n"
     ]
    }
   ],
   "source": [
    "candies = 17\n",
    "group_size = 5\n",
    "print(candies // group_size)\n",
    "print(candies % group_size)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ae9c3cb1",
   "metadata": {},
   "source": [
    "## Эксперимент 1\n",
    "\n",
    "Проверьте divmod() — он должен вернуть оба числа сразу, как кортеж."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "6f92a98f",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-16T12:02:48.743215Z",
     "iopub.status.busy": "2026-08-16T12:02:48.743065Z",
     "iopub.status.idle": "2026-08-16T12:02:48.745697Z",
     "shell.execute_reply": "2026-08-16T12:02:48.745236Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(3, 2)\n"
     ]
    }
   ],
   "source": [
    "print(divmod(17, 5))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c95bda1c",
   "metadata": {},
   "source": [
    "## Задание ★ Базовая практика\n",
    "\n",
    "22 участника делят на команды по 4 человека. Сколько получится полных команд и сколько человек останется без команды? Выведите оба числа через пробел одним print()."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "4d9dfcd3",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-16T12:02:48.747096Z",
     "iopub.status.busy": "2026-08-16T12:02:48.746933Z",
     "iopub.status.idle": "2026-08-16T12:02:48.749742Z",
     "shell.execute_reply": "2026-08-16T12:02:48.749258Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "5 2\n"
     ]
    }
   ],
   "source": [
    "uchastniki = 22\n",
    "razmer_komandy = 4\n",
    "komand, ostatok = divmod(uchastniki, razmer_komandy)\n",
    "print(komand, ostatok)"
   ]
  }
 ],
 "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
}
