{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "1520d7a0",
   "metadata": {},
   "source": [
    "# 04-10 · Podział, reszta i divmod()\n",
    "\n",
    "Praktyka do sekcji [„Podział i reszta”"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5b84a9a1",
   "metadata": {},
   "source": [
    "## Cel\n",
    "\n",
    "Opanować /, // i % na przykładzie z cukierkami, w tym dzielenie floor- z liczbami ujemnymi."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "69baa324",
   "metadata": {},
   "source": [
    "## Sprawa robocza"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "6bda5caf",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-16T10:03:32.197201Z",
     "iopub.status.busy": "2026-08-16T10:03:32.197039Z",
     "iopub.status.idle": "2026-08-16T10:03:32.221783Z",
     "shell.execute_reply": "2026-08-16T10:03:32.221315Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "3\n",
      "2\n"
     ]
    }
   ],
   "source": [
    "candies = 17\n",
    "children = 5\n",
    "print(candies // children)\n",
    "print(candies % children)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "edaa7700",
   "metadata": {},
   "source": [
    "## Eksperyment 1\n",
    "\n",
    "Sprawdź divmod() – powinno zwracać oba numery jednocześnie."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "7cf50827",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-16T10:03:32.222907Z",
     "iopub.status.busy": "2026-08-16T10:03:32.222798Z",
     "iopub.status.idle": "2026-08-16T10:03:32.224936Z",
     "shell.execute_reply": "2026-08-16T10:03:32.224550Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(3, 2)\n"
     ]
    }
   ],
   "source": [
    "print(divmod(17, 5))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "db298951",
   "metadata": {},
   "source": [
    "## Eksperyment 2 · 🚀 Trochę głębiej\n",
    "\n",
    "Przewidź wynik dla liczby ujemnej, potem sprawdź."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "3064cc17",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-16T10:03:32.226048Z",
     "iopub.status.busy": "2026-08-16T10:03:32.225950Z",
     "iopub.status.idle": "2026-08-16T10:03:32.228166Z",
     "shell.execute_reply": "2026-08-16T10:03:32.227723Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "-3\n",
      "2\n"
     ]
    }
   ],
   "source": [
    "print(-7 // 3)\n",
    "print(-7 % 3)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4ba383ed",
   "metadata": {},
   "source": [
    "## Podstawowa praktyka zadań ★\n",
    "\n",
    "23 jabłka dzielą się równo między 4 kosze. Ile jabłek w każdym koszu i ile zostanie?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "a6f14b85",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-16T10:03:32.229075Z",
     "iopub.status.busy": "2026-08-16T10:03:32.228976Z",
     "iopub.status.idle": "2026-08-16T10:03:32.231051Z",
     "shell.execute_reply": "2026-08-16T10:03:32.230647Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "5 3\n"
     ]
    }
   ],
   "source": [
    "apples = 23\n",
    "baskets = 4\n",
    "per_basket = apples // baskets\n",
    "remainder = apples % baskets\n",
    "print(per_basket, remainder)"
   ]
  }
 ],
 "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
}
