{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "58352bef",
   "metadata": {},
   "source": [
    "# 04-03 · Числа бывают разных видов\n",
    "\n",
    "Практика к разделу [«Числа бывают разных видов»](../../site/chapters/glava-04/04-03-vidy-chisel.html)."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8cd76f6f",
   "metadata": {},
   "source": [
    "## Цель\n",
    "\n",
    "Потрогать три числовых типа руками: `int`, `float`, `complex`."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0b7e0a1b",
   "metadata": {},
   "source": [
    "## Что нужно знать\n",
    "\n",
    "`type(значение)` показывает тип значения."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3c139820",
   "metadata": {},
   "source": [
    "## Краткое напоминание\n",
    "\n",
    "`int` — целые, `float` — дробные, `complex` — комплексные (с `j`)."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c78b02bf",
   "metadata": {},
   "source": [
    "## Рабочий пример"
   ]
  },
  {
   "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": [
    "## Эксперимент 1\n",
    "\n",
    "Проверьте тип результата деления `/` и целочисленного деления `//`."
   ]
  },
  {
   "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": [
    "## Эксперимент 2\n",
    "\n",
    "У комплексного числа есть части `.real` и `.imag` — попробуйте."
   ]
  },
  {
   "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": [
    "## Типичная ошибка\n",
    "\n",
    "Легко перепутать `float` с нулевой дробной частью и `int` — они выглядят по-разному только благодаря точке."
   ]
  },
  {
   "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": [
    "## Задание ★ Базовая практика\n",
    "\n",
    "Создайте по одному значению каждого типа (`int`, `float`, `complex`) и выведите тип каждого через `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": [
    "## Дополнительная задача ★★★\n",
    "\n",
    "`10 ** 100` — очень большое целое число. Выведите его и его тип: осталось ли оно `int`, несмотря на огромный размер?"
   ]
  },
  {
   "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
}
