{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "bb87b550",
   "metadata": {},
   "source": [
    "# 08-10 · Мини-проект — динамическая математика\n",
    "\n",
    "Практика к разделу [«Мини-проект — динамическая математика»](../../site/chapters/glava-08/08-10-mini-proekt-matematika-itogi.html)."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d9e80a15",
   "metadata": {},
   "source": [
    "## Цель\n",
    "\n",
    "Собрать ввод, числа, f-строки в одном мини-калькуляторе (без окна Turtle — только логика вычислений и текста)."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "220e3169",
   "metadata": {},
   "source": [
    "## Про input() в этом ноутбуке\n",
    "\n",
    "В обычном `.py`-файле `input()` ждёт, пока вы наберёте текст и нажмёте Enter. Этот ноутбук выполняется автоматически, без живого человека за клавиатурой — поэтому здесь `input()` временно подменён на заранее заготовленные ответы. Сам код с `input()` ниже выглядит и работает точно так же, как в обычном файле, который вы запускаете сами."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "dec16832",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:53:51.524969Z",
     "iopub.status.busy": "2026-08-14T20:53:51.524837Z",
     "iopub.status.idle": "2026-08-14T20:53:51.541254Z",
     "shell.execute_reply": "2026-08-14T20:53:51.540784Z"
    }
   },
   "outputs": [],
   "source": [
    "_answers = iter(['6', '7'])\n",
    "\n",
    "def input(prompt=\"\"):\n",
    "    answer = next(_answers)\n",
    "    print(prompt + answer)\n",
    "    return answer"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "45659fcf",
   "metadata": {},
   "source": [
    "## Рабочий пример"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "2d48760d",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:53:51.543006Z",
     "iopub.status.busy": "2026-08-14T20:53:51.542867Z",
     "iopub.status.idle": "2026-08-14T20:53:51.545429Z",
     "shell.execute_reply": "2026-08-14T20:53:51.544975Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Первое число: 6\n",
      "Второе число: 7\n",
      "6.0 + 7.0 = 13.0\n",
      "6.0 * 7.0 = 42.0\n"
     ]
    }
   ],
   "source": [
    "a = float(input(\"Первое число: \"))\n",
    "b = float(input(\"Второе число: \"))\n",
    "\n",
    "print(f\"{a} + {b} = {a + b}\")\n",
    "print(f\"{a} * {b} = {a * b}\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7282e1fb",
   "metadata": {},
   "source": [
    "## Задание ★★ Самостоятельная задача\n",
    "\n",
    "Добавьте вычитание и деление к выводу."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "fc983cbd",
   "metadata": {},
   "source": [
    "## Про input() в этом ноутбуке\n",
    "\n",
    "В обычном `.py`-файле `input()` ждёт, пока вы наберёте текст и нажмёте Enter. Этот ноутбук выполняется автоматически, без живого человека за клавиатурой — поэтому здесь `input()` временно подменён на заранее заготовленные ответы. Сам код с `input()` ниже выглядит и работает точно так же, как в обычном файле, который вы запускаете сами."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "8d14523d",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:53:51.546429Z",
     "iopub.status.busy": "2026-08-14T20:53:51.546310Z",
     "iopub.status.idle": "2026-08-14T20:53:51.548426Z",
     "shell.execute_reply": "2026-08-14T20:53:51.548013Z"
    }
   },
   "outputs": [],
   "source": [
    "_answers = iter(['10', '4'])\n",
    "\n",
    "def input(prompt=\"\"):\n",
    "    answer = next(_answers)\n",
    "    print(prompt + answer)\n",
    "    return answer"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "7df26834",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:53:51.549466Z",
     "iopub.status.busy": "2026-08-14T20:53:51.549355Z",
     "iopub.status.idle": "2026-08-14T20:53:51.551994Z",
     "shell.execute_reply": "2026-08-14T20:53:51.551491Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Первое число: 10\n",
      "Второе число: 4\n",
      "10.0 + 4.0 = 14.0\n",
      "10.0 - 4.0 = 6.0\n",
      "10.0 * 4.0 = 40.0\n",
      "10.0 / 4.0 = 2.5\n"
     ]
    }
   ],
   "source": [
    "a = float(input(\"Первое число: \"))\n",
    "b = float(input(\"Второе число: \"))\n",
    "\n",
    "print(f\"{a} + {b} = {a + b}\")\n",
    "print(f\"{a} - {b} = {a - b}\")\n",
    "print(f\"{a} * {b} = {a * b}\")\n",
    "print(f\"{a} / {b} = {a / b}\")"
   ]
  }
 ],
 "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
}
