{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "8b6ac8fb",
   "metadata": {},
   "source": [
    "# 04-05 · Мини-проект — Понимаете ли вы числа?\n",
    "\n",
    "Практика к разделу [«Мини-проект — Понимаете ли вы числа?»](../../site/chapters/glava-04/04-05-mini-proekt-itogi.html)."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "11380db1",
   "metadata": {},
   "source": [
    "## Цель\n",
    "\n",
    "Проверить понимание чисел и типов — сначала угадать, потом проверить запуском."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "416751e0",
   "metadata": {},
   "source": [
    "## Задание ★ Базовая практика\n",
    "\n",
    "Сначала запишите на бумаге (или в уме) ваш ответ для каждого выражения, и только потом\n",
    "запускайте ячейку и сверяйтесь:\n",
    "\n",
    "1. Тип `10`\n",
    "2. Тип `10.0`\n",
    "3. Тип `10 / 2`\n",
    "4. Тип `10 // 2`\n",
    "5. Тип `\"10\"`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "e63ee905",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:52:15.972773Z",
     "iopub.status.busy": "2026-08-14T20:52:15.972360Z",
     "iopub.status.idle": "2026-08-14T20:52:15.999387Z",
     "shell.execute_reply": "2026-08-14T20:52:15.998701Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'int'>\n",
      "<class 'float'>\n",
      "<class 'float'>\n",
      "<class 'int'>\n",
      "<class 'str'>\n"
     ]
    }
   ],
   "source": [
    "print(type(10))\n",
    "print(type(10.0))\n",
    "print(type(10 / 2))\n",
    "print(type(10 // 2))\n",
    "print(type(\"10\"))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "eef7c241",
   "metadata": {},
   "source": [
    "## Проверка результата"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "3404111d",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:52:16.000680Z",
     "iopub.status.busy": "2026-08-14T20:52:16.000518Z",
     "iopub.status.idle": "2026-08-14T20:52:16.004619Z",
     "shell.execute_reply": "2026-08-14T20:52:16.003782Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Все пять ответов верны!\n"
     ]
    }
   ],
   "source": [
    "assert type(10) is int\n",
    "assert type(10.0) is float\n",
    "assert type(10 / 2) is float\n",
    "assert type(10 // 2) is int\n",
    "assert type(\"10\") is str\n",
    "print(\"Все пять ответов верны!\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f65b4e7c",
   "metadata": {},
   "source": [
    "## Задание ★★ Самостоятельная задача\n",
    "\n",
    "Что выведет `print(str(7) + str(9))` — число 16 или что-то другое? Предскажите, затем\n",
    "проверьте."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "9628052c",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:52:16.006043Z",
     "iopub.status.busy": "2026-08-14T20:52:16.005886Z",
     "iopub.status.idle": "2026-08-14T20:52:16.010636Z",
     "shell.execute_reply": "2026-08-14T20:52:16.008376Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "79\n"
     ]
    }
   ],
   "source": [
    "print(str(7) + str(9))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7aabc236",
   "metadata": {},
   "source": [
    "## Дополнительная задача ★★★\n",
    "\n",
    "Почему `\"Итого: \" + 100` вызывает ошибку, а `\"Итого: \" + str(100)` — нет? Продемонстрируйте оба варианта."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "a8533ee4",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:52:16.012558Z",
     "iopub.status.busy": "2026-08-14T20:52:16.012391Z",
     "iopub.status.idle": "2026-08-14T20:52:16.052414Z",
     "shell.execute_reply": "2026-08-14T20:52:16.051847Z"
    },
    "tags": [
     "raises-exception"
    ]
   },
   "outputs": [
    {
     "ename": "TypeError",
     "evalue": "can only concatenate str (not \"int\") to str",
     "output_type": "error",
     "traceback": [
      "\u001b[31m---------------------------------------------------------------------------\u001b[39m",
      "\u001b[31mTypeError\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(\u001b[33m\"Итого: \"\u001b[39m + \u001b[32m100\u001b[39m)\n",
      "\u001b[31mTypeError\u001b[39m: can only concatenate str (not \"int\") to str"
     ]
    }
   ],
   "source": [
    "print(\"Итого: \" + 100)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "d351feb0",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:52:16.053836Z",
     "iopub.status.busy": "2026-08-14T20:52:16.053655Z",
     "iopub.status.idle": "2026-08-14T20:52:16.056496Z",
     "shell.execute_reply": "2026-08-14T20:52:16.055955Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Итого: 100\n"
     ]
    }
   ],
   "source": [
    "print(\"Итого: \" + str(100))"
   ]
  }
 ],
 "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
}
