{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "4af84d7a",
   "metadata": {},
   "source": [
    "# 03-02 · Tryb interaktywny (Python Shell)\n",
    "\n",
    "Praktyka do sekcji [„Interaktywny tryb Python (Python Shell)”](/pl/chapters/rozdzial-03/03-02-interaktivny-rezhim.html)."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "96e33714",
   "metadata": {},
   "source": [
    "## Cel\n",
    "\n",
    "Zrozum, czym interaktywna powłoka różni się od zwykłego pliku — i zauważ, że Jupyter laptopa jest bardzo podobny."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2fd3be04",
   "metadata": {},
   "source": [
    "## Co trzeba wiedzieć\n",
    "\n",
    "W Python Shell (`>>>`) każda wprowadzona łańcuch znaków od razu pokazuje wynik."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6c78effc",
   "metadata": {},
   "source": [
    "## Krótkie przypomnienie\n",
    "\n",
    "W prawdziwej powłoce `>>> 2 + 2` natychmiast odbija `4` — bez `print()`. Sprawdźmy, czy to samo działa w Jupyter. komórce"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "19d6ff7c",
   "metadata": {},
   "source": [
    "## Sprawa robocza"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "c72648f6",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:52:10.988957Z",
     "iopub.status.busy": "2026-08-14T20:52:10.988855Z",
     "iopub.status.idle": "2026-08-14T20:52:11.006681Z",
     "shell.execute_reply": "2026-08-14T20:52:11.006179Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "4"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "2 + 2"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2e72a467",
   "metadata": {},
   "source": [
    "## Eksperyment 1\n",
    "\n",
    "Zadziałało! Komórka Jupyter, podobnie jak Python Shell, automatycznie pokazuje wynik **najnowszego**\n",
    "wyrażeniach w komórce, oba opierają się na tej samej idei REPL. Ale to działa tylko\n",
    "na *ostatnią* linijkę, sprawdźmy."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "a3e1675a",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:52:11.007809Z",
     "iopub.status.busy": "2026-08-14T20:52:11.007690Z",
     "iopub.status.idle": "2026-08-14T20:52:11.010722Z",
     "shell.execute_reply": "2026-08-14T20:52:11.010310Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "6"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "1 + 1\n",
    "2 + 2\n",
    "3 + 3"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5f57bb16",
   "metadata": {},
   "source": [
    "## Eksperyment 2\n",
    "\n",
    "A jeśli potrzebujesz wyniku na każdej linii, użyj `print()`jak w zwykłym pliku."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "e799bca8",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:52:11.011821Z",
     "iopub.status.busy": "2026-08-14T20:52:11.011689Z",
     "iopub.status.idle": "2026-08-14T20:52:11.014147Z",
     "shell.execute_reply": "2026-08-14T20:52:11.013696Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2\n",
      "4\n",
      "6\n"
     ]
    }
   ],
   "source": [
    "print(1 + 1)\n",
    "print(2 + 2)\n",
    "print(3 + 3)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "33ab90bb",
   "metadata": {},
   "source": [
    "## Typowy błąd\n",
    "\n",
    "W prawdziwej powłoce `>>> имя = \"Cartesian\"` **nie** drukuje wynik, samo zadanie\n",
    "samo w sobie nie jest wyrażeniem o znaczeniu do pokazania. Początkujący czasem czekają na zakończenie po nim\n",
    "przypisania i dziwią się, że go nie ma."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "cc8def39",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:52:11.015146Z",
     "iopub.status.busy": "2026-08-14T20:52:11.015038Z",
     "iopub.status.idle": "2026-08-14T20:52:11.016973Z",
     "shell.execute_reply": "2026-08-14T20:52:11.016557Z"
    }
   },
   "outputs": [],
   "source": [
    "name = \"Cartesian\"  # ничего не выводится — это нормально"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f9e24a41",
   "metadata": {},
   "source": [
    "## Poprawka\n",
    "\n",
    "Aby zobaczyć wartość zmiennej, trzeba ją wyświetlić osobno."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "081c6bc2",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:52:11.017917Z",
     "iopub.status.busy": "2026-08-14T20:52:11.017820Z",
     "iopub.status.idle": "2026-08-14T20:52:11.019854Z",
     "shell.execute_reply": "2026-08-14T20:52:11.019388Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Cartesian\n"
     ]
    }
   ],
   "source": [
    "name = \"Cartesian\"\n",
    "print(name)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8ee7a265",
   "metadata": {},
   "source": [
    "## Podstawowa praktyka zadań ★\n",
    "\n",
    "W jednej komórce zapisz trzy wyrażenia arytmetyczne w rzędzie i opakuj każde w `print()`zobaczyć wszystkie trzy wyniki."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "2da67db8",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:52:11.020738Z",
     "iopub.status.busy": "2026-08-14T20:52:11.020640Z",
     "iopub.status.idle": "2026-08-14T20:52:11.022980Z",
     "shell.execute_reply": "2026-08-14T20:52:11.022481Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "10\n",
      "5\n",
      "36\n"
     ]
    }
   ],
   "source": [
    "print(5 + 5)\n",
    "print(9 - 4)\n",
    "print(6 * 6)"
   ]
  }
 ],
 "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
}
