{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "77fefa58",
   "metadata": {},
   "source": [
    "# 14-02 · Klasy\n",
    "\n",
    "Praktyka do sekcji [„Klasy”"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3fb1d82e",
   "metadata": {},
   "source": [
    "## Cel\n",
    "\n",
    "Zdefiniuj własną klasę i stwórz wiele funkcji."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6750b15e",
   "metadata": {},
   "source": [
    "## Sprawa robocza"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "0e6de866",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-17T19:47:44.619690Z",
     "iopub.status.busy": "2026-08-17T19:47:44.619529Z",
     "iopub.status.idle": "2026-08-17T19:47:44.636896Z",
     "shell.execute_reply": "2026-08-17T19:47:44.636393Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Рекс 3\n"
     ]
    }
   ],
   "source": [
    "class Sobaka:\n",
    "    def __init__(self, klichka, vozrast):\n",
    "        self.klichka = klichka\n",
    "        self.vozrast = vozrast\n",
    "\n",
    "rex = Sobaka(\"Рекс\", 3)\n",
    "print(rex.klichka, rex.vozrast)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ccd339f3",
   "metadata": {},
   "source": [
    "## Eksperyment 1 — niezależne obiekty"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "09f695e6",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-17T19:47:44.637900Z",
     "iopub.status.busy": "2026-08-17T19:47:44.637790Z",
     "iopub.status.idle": "2026-08-17T19:47:44.640330Z",
     "shell.execute_reply": "2026-08-17T19:47:44.639865Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Рекс 3\n",
      "Шарик 5\n"
     ]
    }
   ],
   "source": [
    "rex = Sobaka(\"Рекс\", 3)\n",
    "sharik = Sobaka(\"Шарик\", 5)\n",
    "\n",
    "print(rex.klichka, rex.vozrast)\n",
    "print(sharik.klichka, sharik.vozrast)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6e4337b5",
   "metadata": {},
   "source": [
    "## Podstawowa praktyka zadań ★\n",
    "\n",
    "Utwórz klasę `Kniga` z atrybutami `nazvanie` oraz `avtor`, a następnie stwórz trzy obiekty."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "c9d756e6",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-17T19:47:44.641282Z",
     "iopub.status.busy": "2026-08-17T19:47:44.641175Z",
     "iopub.status.idle": "2026-08-17T19:47:44.643857Z",
     "shell.execute_reply": "2026-08-17T19:47:44.643415Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Война и мир — Толстой\n",
      "Мастер и Маргарита — Булгаков\n",
      "Преступление и наказание — Достоевский\n"
     ]
    }
   ],
   "source": [
    "class Kniga:\n",
    "    def __init__(self, nazvanie, avtor):\n",
    "        self.nazvanie = nazvanie\n",
    "        self.avtor = avtor\n",
    "\n",
    "knigi = [\n",
    "    Kniga(\"Война и мир\", \"Толстой\"),\n",
    "    Kniga(\"Мастер и Маргарита\", \"Булгаков\"),\n",
    "    Kniga(\"Преступление и наказание\", \"Достоевский\"),\n",
    "]\n",
    "\n",
    "for k in knigi:\n",
    "    print(f\"{k.nazvanie} — {k.avtor}\")"
   ]
  }
 ],
 "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
}
