{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "58352bef",
   "metadata": {},
   "source": [
    "# 04-03 · Numery występują różnych typów\n",
    "\n",
    "Praktyka do rozdziału [„Liczby są różnego rodzaju”](/pl/chapters/rozdzial-04/04-03-vidy-chisel.html)."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8cd76f6f",
   "metadata": {},
   "source": [
    "## Cel\n",
    "\n",
    "Dotknij trzech typów liczb rękami: `int`, `float`, `complex`."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0b7e0a1b",
   "metadata": {},
   "source": [
    "## Co trzeba wiedzieć\n",
    "\n",
    "`type(значение)` pokazuje rodzaj wartości."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3c139820",
   "metadata": {},
   "source": [
    "## Krótkie przypomnienie\n",
    "\n",
    "`int` — całość, `float` — ułamkowa, `complex` — zespolona (z `j`)."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c78b02bf",
   "metadata": {},
   "source": [
    "## Sprawa robocza"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "ca4adeb8",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:52:14.319875Z",
     "iopub.status.busy": "2026-08-14T20:52:14.319546Z",
     "iopub.status.idle": "2026-08-14T20:52:14.342284Z",
     "shell.execute_reply": "2026-08-14T20:52:14.341428Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'int'>\n",
      "<class 'float'>\n",
      "<class 'complex'>\n"
     ]
    }
   ],
   "source": [
    "print(type(10))\n",
    "print(type(10.0))\n",
    "print(type(3 + 4j))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ac9d1a3e",
   "metadata": {},
   "source": [
    "## Eksperyment 1\n",
    "\n",
    "Sprawdź rodzaj wyniku dywizji `/` i podział całkowitych `//`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "1de0644b",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:52:14.343330Z",
     "iopub.status.busy": "2026-08-14T20:52:14.343209Z",
     "iopub.status.idle": "2026-08-14T20:52:14.345418Z",
     "shell.execute_reply": "2026-08-14T20:52:14.345043Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "5.0 <class 'float'>\n",
      "5 <class 'int'>\n"
     ]
    }
   ],
   "source": [
    "print(10 / 2, type(10 / 2))\n",
    "print(10 // 2, type(10 // 2))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2f9b6d5d",
   "metadata": {},
   "source": [
    "## Eksperyment 2\n",
    "\n",
    "Liczba zespolona ma części `.real` oraz `.imag` – spróbuj."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "82f2a1bb",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:52:14.346682Z",
     "iopub.status.busy": "2026-08-14T20:52:14.346527Z",
     "iopub.status.idle": "2026-08-14T20:52:14.348898Z",
     "shell.execute_reply": "2026-08-14T20:52:14.348435Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "3.0\n",
      "4.0\n"
     ]
    }
   ],
   "source": [
    "z = 3 + 4j\n",
    "print(z.real)\n",
    "print(z.imag)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0773cb02",
   "metadata": {},
   "source": [
    "## Typowy błąd\n",
    "\n",
    "Łatwo pomylić `float` z zerową częścią ułamkową i `int` – wyglądają inaczej tylko przez kropkę."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "416266ca",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:52:14.349882Z",
     "iopub.status.busy": "2026-08-14T20:52:14.349773Z",
     "iopub.status.idle": "2026-08-14T20:52:14.351977Z",
     "shell.execute_reply": "2026-08-14T20:52:14.351593Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "True\n",
      "False\n"
     ]
    }
   ],
   "source": [
    "a = 2\n",
    "b = 2.0\n",
    "print(a == b)       # True — значения равны\n",
    "print(type(a) == type(b))  # False — типы разные"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8b1adba9",
   "metadata": {},
   "source": [
    "## Podstawowa praktyka zadań ★\n",
    "\n",
    "Stwórz jedną wartość każdego typu (`int`, `float`, `complex`) i wyjść typ każdego z nich do `type()`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "c4dd68e9",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:52:14.352978Z",
     "iopub.status.busy": "2026-08-14T20:52:14.352859Z",
     "iopub.status.idle": "2026-08-14T20:52:14.355054Z",
     "shell.execute_reply": "2026-08-14T20:52:14.354678Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'int'> <class 'float'> <class 'complex'>\n"
     ]
    }
   ],
   "source": [
    "i = 42\n",
    "f = 3.14\n",
    "c = 1 + 2j\n",
    "print(type(i), type(f), type(c))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "855e42ac",
   "metadata": {},
   "source": [
    "## Zadanie dodatkowe ★★★\n",
    "\n",
    "`10 ** 100` jest bardzo dużą liczbą całkowitą. Wyjdź ją i jej typ: czy pozostaje `int`mimo ogromnych rozmiarów?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "67de12fe",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:52:14.355967Z",
     "iopub.status.busy": "2026-08-14T20:52:14.355862Z",
     "iopub.status.idle": "2026-08-14T20:52:14.358240Z",
     "shell.execute_reply": "2026-08-14T20:52:14.357686Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'int'>\n",
      "101 цифр\n"
     ]
    }
   ],
   "source": [
    "huge = 10 ** 100\n",
    "print(type(huge))\n",
    "print(len(str(huge)), \"цифр\")"
   ]
  }
 ],
 "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
}
