{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "e049e414",
   "metadata": {},
   "source": [
    "# 03-07 · Imiona i znaczenia\n",
    "\n",
    "Praktyka do sekcji [„Imiona i znaczenia”"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4affa81d",
   "metadata": {},
   "source": [
    "## Cel\n",
    "\n",
    "Ćwicz tworzenie nazw (zmiennych) i ponowne uzyskiwanie do nich – bez błędów `NameError`."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1972005b",
   "metadata": {},
   "source": [
    "## Co trzeba wiedzieć\n",
    "\n",
    "`имя = значение` tworzy nazwę wskazującą na daną wartość. Można wtedy użyć nazwy zamiast samej wartości."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d09bf1fa",
   "metadata": {},
   "source": [
    "## Krótkie przypomnienie\n",
    "\n",
    "Bardziej poprawne jest myślenie nie \"nazwa to pudełko z znaczeniem\", lecz \"nazwa wskazuje znaczenie\" – jak strzałka. Kilka nazw może mieć jednocześnie to samo znaczenie."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "365b8066",
   "metadata": {},
   "source": [
    "## Sprawa robocza"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "60ef36b0",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-16T01:25:11.479004Z",
     "iopub.status.busy": "2026-08-16T01:25:11.478853Z",
     "iopub.status.idle": "2026-08-16T01:25:11.497783Z",
     "shell.execute_reply": "2026-08-16T01:25:11.497300Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Warsaw\n"
     ]
    }
   ],
   "source": [
    "city = \"Warsaw\"\n",
    "print(city)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "895fd42e",
   "metadata": {},
   "source": [
    "## Eksperyment 1\n",
    "\n",
    "Stwórz drugie imię, które wskazuje na tę samą wartość i sprawdź, czy obie nazwy działają."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "5b9ea7ab",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-16T01:25:11.498802Z",
     "iopub.status.busy": "2026-08-16T01:25:11.498693Z",
     "iopub.status.idle": "2026-08-16T01:25:11.500960Z",
     "shell.execute_reply": "2026-08-16T01:25:11.500492Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Warsaw\n",
      "Warsaw\n"
     ]
    }
   ],
   "source": [
    "city = \"Warsaw\"\n",
    "town = city\n",
    "print(city)\n",
    "print(town)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "19913512",
   "metadata": {},
   "source": [
    "## Eksperyment 2\n",
    "\n",
    "Nadpisz znaczenie jednej z nazw i upewnij się, że druga nazwa się nie zmieniła – przypisanie się zmienia, co jest oznaczane DOKŁADNIE TĄ nazwą, a nie wszystkim, co się do niej odnosiło."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "d54fdec4",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-16T01:25:11.501864Z",
     "iopub.status.busy": "2026-08-16T01:25:11.501765Z",
     "iopub.status.idle": "2026-08-16T01:25:11.503782Z",
     "shell.execute_reply": "2026-08-16T01:25:11.503388Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Krakow\n",
      "Warsaw\n"
     ]
    }
   ],
   "source": [
    "city = \"Warsaw\"\n",
    "town = city\n",
    "city = \"Krakow\"\n",
    "print(city)\n",
    "print(town)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "13b10883",
   "metadata": {},
   "source": [
    "## Typowy błąd\n",
    "\n",
    "Odwołanie do nazwy, która jeszcze nie została utworzona (literówka lub niewłaściwa kolejność wierszy), daje `NameError`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "293d4eec",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-16T01:25:11.504651Z",
     "iopub.status.busy": "2026-08-16T01:25:11.504550Z",
     "iopub.status.idle": "2026-08-16T01:25:11.529413Z",
     "shell.execute_reply": "2026-08-16T01:25:11.528957Z"
    },
    "tags": [
     "raises-exception"
    ]
   },
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'favourite_city' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[31m---------------------------------------------------------------------------\u001b[39m",
      "\u001b[31mNameError\u001b[39m                                 Traceback (most recent call last)",
      "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[4]\u001b[39m\u001b[32m, line 1\u001b[39m\n\u001b[32m----> \u001b[39m\u001b[32m1\u001b[39m print(favourite_city)\n\u001b[32m      2\u001b[39m favourite_city = \u001b[33m\"Warsaw\"\u001b[39m\n",
      "\u001b[31mNameError\u001b[39m: name 'favourite_city' is not defined"
     ]
    }
   ],
   "source": [
    "print(favourite_city)\n",
    "favourite_city = \"Warsaw\""
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8b024fc4",
   "metadata": {},
   "source": [
    "## Poprawka\n",
    "\n",
    "Nazwa musi zostać utworzona przez przypisanie PRZED uzyskaniem dostępu."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "1841495a",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-16T01:25:11.531445Z",
     "iopub.status.busy": "2026-08-16T01:25:11.531273Z",
     "iopub.status.idle": "2026-08-16T01:25:11.535201Z",
     "shell.execute_reply": "2026-08-16T01:25:11.534628Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Warsaw\n"
     ]
    }
   ],
   "source": [
    "favourite_city = \"Warsaw\"\n",
    "print(favourite_city)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0bcf6aa4",
   "metadata": {},
   "source": [
    "## Podstawowa praktyka zadań ★\n",
    "\n",
    "Stwórz trzy imiona – `name`, `city`, `hobby` — i wypisuje je jednym poleceniem `print()` oddzielone przecinkami."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "f97a5a34",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-16T01:25:11.536576Z",
     "iopub.status.busy": "2026-08-16T01:25:11.536453Z",
     "iopub.status.idle": "2026-08-16T01:25:11.539413Z",
     "shell.execute_reply": "2026-08-16T01:25:11.538940Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Cartesian Warsaw Python\n"
     ]
    }
   ],
   "source": [
    "name = \"Cartesian\"\n",
    "city = \"Warsaw\"\n",
    "hobby = \"Python\"\n",
    "print(name, city, hobby)"
   ]
  }
 ],
 "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
}
