{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "09b8c863",
   "metadata": {},
   "source": [
    "# 04-09 · Napraw kolejność operacji\n",
    "\n",
    "Praktyka do sekcji [«Kolejność wykonywania operacji»](/pl/chapters/rozdzial-04/04-09-poryadok-operacij.html)."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7b1637bc",
   "metadata": {},
   "source": [
    "## Cel\n",
    "\n",
    "Przewidzieć wynik wyrażeń z uwzględnieniem priorytetu operatorów."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "10e6c30a",
   "metadata": {},
   "source": [
    "## Sprawa robocza"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "c6045db5",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-16T10:03:22.774463Z",
     "iopub.status.busy": "2026-08-16T10:03:22.774354Z",
     "iopub.status.idle": "2026-08-16T10:03:22.789703Z",
     "shell.execute_reply": "2026-08-16T10:03:22.789259Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "14\n"
     ]
    }
   ],
   "source": [
    "print(2 + 3 * 4)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "fe5f2633",
   "metadata": {},
   "source": [
    "## Eksperyment 1\n",
    "\n",
    "Przewiduj, a potem sprawdź — jak nawiasy zmieniają wynik."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "d658815d",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-16T10:03:22.790909Z",
     "iopub.status.busy": "2026-08-16T10:03:22.790804Z",
     "iopub.status.idle": "2026-08-16T10:03:22.793075Z",
     "shell.execute_reply": "2026-08-16T10:03:22.792653Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "20\n"
     ]
    }
   ],
   "source": [
    "print((2 + 3) * 4)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c0510182",
   "metadata": {},
   "source": [
    "## Podstawowa praktyka zadań ★\n",
    "\n",
    "Ekspresja `10 - 2 ** 2` powinno dać 6 bez nawiasów – sprawdź, czy priorytet ** jest wyższy niż -."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "f5171db2",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-16T10:03:22.794083Z",
     "iopub.status.busy": "2026-08-16T10:03:22.793980Z",
     "iopub.status.idle": "2026-08-16T10:03:22.796208Z",
     "shell.execute_reply": "2026-08-16T10:03:22.795756Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "6\n"
     ]
    }
   ],
   "source": [
    "print(10 - 2 ** 2)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0afbfbc4",
   "metadata": {},
   "source": [
    "## Samodzielna praktyka ★★\n",
    "\n",
    "Rozmieść nawiasy tak, aby `2 + 3 * 4 - 1` dało 19 (a nie 13)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "a379278e",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-16T10:03:22.797046Z",
     "iopub.status.busy": "2026-08-16T10:03:22.796952Z",
     "iopub.status.idle": "2026-08-16T10:03:22.799158Z",
     "shell.execute_reply": "2026-08-16T10:03:22.798692Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "19\n"
     ]
    }
   ],
   "source": [
    "print((2 + 3) * (4 - 1) + 4)"
   ]
  }
 ],
 "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
}
