{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "e96837c9",
   "metadata": {},
   "source": [
    "# 13-03 · Zwracamy odpowiedź\n",
    "\n",
    "Praktyka do sekcji [„Zwracanie odpowiedzi”"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "26e1f033",
   "metadata": {},
   "source": [
    "## Cel\n",
    "\n",
    "Opanować return i różnicę między return a print()."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f1eae2ef",
   "metadata": {},
   "source": [
    "## Sprawa robocza"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "eb0981a3",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-17T18:53:39.793840Z",
     "iopub.status.busy": "2026-08-17T18:53:39.793683Z",
     "iopub.status.idle": "2026-08-17T18:53:39.816883Z",
     "shell.execute_reply": "2026-08-17T18:53:39.816338Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "12\n",
      "50\n"
     ]
    }
   ],
   "source": [
    "def summa(a, b):\n",
    "    return a + b\n",
    "\n",
    "result = summa(5, 7)\n",
    "print(result)\n",
    "print(summa(2, 3) * 10)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "397432d3",
   "metadata": {},
   "source": [
    "## Eksperyment 1 – Różnica między print() a return"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "b286e402",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-17T18:53:39.818356Z",
     "iopub.status.busy": "2026-08-17T18:53:39.818227Z",
     "iopub.status.idle": "2026-08-17T18:53:39.820872Z",
     "shell.execute_reply": "2026-08-17T18:53:39.820495Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "12\n",
      "x = None\n"
     ]
    }
   ],
   "source": [
    "def summa_pechataet(a, b):\n",
    "    print(a + b)\n",
    "\n",
    "x = summa_pechataet(5, 7)\n",
    "print(\"x =\", x)  # None — функция ничего не вернула!"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "19a6d2fb",
   "metadata": {},
   "source": [
    "## Podstawowa praktyka zadań ★\n",
    "\n",
    "Napisz funkcję `plosch_pryamougolnika(width, height)` – tym razem z return zamiast print() i wykorzystaj efekt."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "3af97f7b",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-17T18:53:39.822120Z",
     "iopub.status.busy": "2026-08-17T18:53:39.821943Z",
     "iopub.status.idle": "2026-08-17T18:53:39.824428Z",
     "shell.execute_reply": "2026-08-17T18:53:39.824007Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Первая площадь: 15, вторая: 100, сумма площадей: 115\n"
     ]
    }
   ],
   "source": [
    "def plosch_pryamougolnika(width, height):\n",
    "    return width * height\n",
    "\n",
    "a1 = plosch_pryamougolnika(5, 3)\n",
    "a2 = plosch_pryamougolnika(10, 10)\n",
    "print(f\"Первая площадь: {a1}, вторая: {a2}, сумма площадей: {a1 + a2}\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4e3145e5",
   "metadata": {},
   "source": [
    "## Sprawdzenie wyniku"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "08545c3b",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-17T18:53:39.825639Z",
     "iopub.status.busy": "2026-08-17T18:53:39.825454Z",
     "iopub.status.idle": "2026-08-17T18:53:39.829220Z",
     "shell.execute_reply": "2026-08-17T18:53:39.828595Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Обе проверки пройдены.\n"
     ]
    }
   ],
   "source": [
    "def plosch_pryamougolnika(width, height):\n",
    "    return width * height\n",
    "\n",
    "assert plosch_pryamougolnika(5, 3) == 15\n",
    "assert plosch_pryamougolnika(10, 10) == 100\n",
    "print(\"Обе проверки пройдены.\")"
   ]
  }
 ],
 "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
}
