{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "7ba8ad43",
   "metadata": {},
   "source": [
    "# 11-07 · Zbiory\n",
    "\n",
    "Praktyka do sekcji [„Zbiory”](/pl/chapters/rozdzial-11/11-07-mnozhestva.html)."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "786b622f",
   "metadata": {},
   "source": [
    "## Cel\n",
    "\n",
    "Opanuj set i operacje za pomocą scenografii."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "45ac7bd8",
   "metadata": {},
   "source": [
    "## Sprawa robocza"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "131bac47",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-17T14:44:26.725280Z",
     "iopub.status.busy": "2026-08-17T14:44:26.725169Z",
     "iopub.status.idle": "2026-08-17T14:44:26.748680Z",
     "shell.execute_reply": "2026-08-17T14:44:26.748233Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{1, 2, 3}\n"
     ]
    }
   ],
   "source": [
    "chisla = {1, 2, 2, 3, 3, 3}\n",
    "print(chisla)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5f8f5bbc",
   "metadata": {},
   "source": [
    "## Eksperyment 1 – Usuwanie powtórek z listy"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "53749ba6",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-17T14:44:26.749929Z",
     "iopub.status.busy": "2026-08-17T14:44:26.749758Z",
     "iopub.status.idle": "2026-08-17T14:44:26.752025Z",
     "shell.execute_reply": "2026-08-17T14:44:26.751706Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{1, 2, 3, 4}\n",
      "4 уникальных значений\n"
     ]
    }
   ],
   "source": [
    "spisok_s_povtorami = [1, 2, 2, 3, 1, 4, 4, 4]\n",
    "unikalnye = set(spisok_s_povtorami)\n",
    "print(unikalnye)\n",
    "print(len(unikalnye), \"уникальных значений\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6dea5aa1",
   "metadata": {},
   "source": [
    "## Eksperyment 2 — operacje na zbiorach"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "a9c42926",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-17T14:44:26.753157Z",
     "iopub.status.busy": "2026-08-17T14:44:26.753048Z",
     "iopub.status.idle": "2026-08-17T14:44:26.755420Z",
     "shell.execute_reply": "2026-08-17T14:44:26.755038Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Объединение: {1, 2, 3, 4}\n",
      "Пересечение: {2, 3}\n",
      "Разность a-b: {1}\n",
      "Разность b-a: {4}\n"
     ]
    }
   ],
   "source": [
    "a = {1, 2, 3}\n",
    "b = {2, 3, 4}\n",
    "print(\"Объединение:\", a | b)\n",
    "print(\"Пересечение:\", a & b)\n",
    "print(\"Разность a-b:\", a - b)\n",
    "print(\"Разность b-a:\", b - a)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8bb2485b",
   "metadata": {},
   "source": [
    "## Podstawowa praktyka zadań ★\n",
    "\n",
    "Znajdź wspólnych uczestników dwóch list (część wspólna zbiorów)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "128cd9c8",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-17T14:44:26.756487Z",
     "iopub.status.busy": "2026-08-17T14:44:26.756390Z",
     "iopub.status.idle": "2026-08-17T14:44:26.758589Z",
     "shell.execute_reply": "2026-08-17T14:44:26.758237Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'Вера', 'Гриша'}\n"
     ]
    }
   ],
   "source": [
    "group_a = [\"Аня\", \"Боря\", \"Вера\", \"Гриша\"]\n",
    "group_b = [\"Вера\", \"Гриша\", \"Даша\"]\n",
    "common = set(group_a) & set(group_b)\n",
    "print(common)"
   ]
  }
 ],
 "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
}
