{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "857eebd0",
   "metadata": {},
   "source": [
    "# 03-03 · Ваша оболочка умеет считать\n",
    "\n",
    "Практика к разделу [«Ваша оболочка умеет считать»](../../site/chapters/glava-03/03-02-interaktivny-rezhim.html#schitaet)."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "96877aec",
   "metadata": {},
   "source": [
    "## Цель\n",
    "\n",
    "Использовать Python как калькулятор — сложение, вычитание, умножение, деление."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e3f4adb3",
   "metadata": {},
   "source": [
    "## Что нужно знать\n",
    "\n",
    "Основные знаки: `+`, `-`, `*` (умножение), `/` (деление)."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2d5c0b49",
   "metadata": {},
   "source": [
    "## Краткое напоминание\n",
    "\n",
    "`/` всегда возвращает дробное число, даже если результат делится нацело — подробнее об этом в главе 4."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ac5e0b0c",
   "metadata": {},
   "source": [
    "## Рабочий пример"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "8d7ea76c",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:52:11.832592Z",
     "iopub.status.busy": "2026-08-14T20:52:11.832481Z",
     "iopub.status.idle": "2026-08-14T20:52:11.853608Z",
     "shell.execute_reply": "2026-08-14T20:52:11.853173Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "4\n",
      "6\n",
      "21\n",
      "2.5\n"
     ]
    }
   ],
   "source": [
    "print(2 + 2)\n",
    "print(10 - 4)\n",
    "print(3 * 7)\n",
    "print(10 / 4)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "356c4fc3",
   "metadata": {},
   "source": [
    "## Эксперимент 1\n",
    "\n",
    "Попробуйте разделить два числа так, чтобы результат делился нацело — например, 10 на 2. Каким будет результат: `5` или `5.0`?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "0c3f666e",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:52:11.854866Z",
     "iopub.status.busy": "2026-08-14T20:52:11.854740Z",
     "iopub.status.idle": "2026-08-14T20:52:11.856936Z",
     "shell.execute_reply": "2026-08-14T20:52:11.856520Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "5.0\n"
     ]
    }
   ],
   "source": [
    "print(10 / 2)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0be79c87",
   "metadata": {},
   "source": [
    "## Эксперимент 2\n",
    "\n",
    "Порядок операций в Python такой же, как в математике: сначала умножение и деление, потом сложение и вычитание. Проверьте."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "71077108",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:52:11.857963Z",
     "iopub.status.busy": "2026-08-14T20:52:11.857836Z",
     "iopub.status.idle": "2026-08-14T20:52:11.860313Z",
     "shell.execute_reply": "2026-08-14T20:52:11.859960Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "14\n",
      "20\n"
     ]
    }
   ],
   "source": [
    "print(2 + 3 * 4)   # сначала 3 * 4, потом + 2\n",
    "print((2 + 3) * 4) # скобки меняют порядок"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "52946e9e",
   "metadata": {},
   "source": [
    "## Задание ★ Базовая практика\n",
    "\n",
    "Посчитайте, сколько минут в трёх с половиной часах, используя выражение с `*`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "42f4b88d",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:52:11.861418Z",
     "iopub.status.busy": "2026-08-14T20:52:11.861310Z",
     "iopub.status.idle": "2026-08-14T20:52:11.863370Z",
     "shell.execute_reply": "2026-08-14T20:52:11.862901Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "210.0\n"
     ]
    }
   ],
   "source": [
    "print(3.5 * 60)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4793352e",
   "metadata": {},
   "source": [
    "## Проверка результата"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "00aad64d",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:52:11.864356Z",
     "iopub.status.busy": "2026-08-14T20:52:11.864175Z",
     "iopub.status.idle": "2026-08-14T20:52:11.866528Z",
     "shell.execute_reply": "2026-08-14T20:52:11.866060Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Проверка пройдена: 210 минут.\n"
     ]
    }
   ],
   "source": [
    "assert 3.5 * 60 == 210.0\n",
    "print(\"Проверка пройдена: 210 минут.\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b47ee15c",
   "metadata": {},
   "source": [
    "## Дополнительная задача ★★★\n",
    "\n",
    "Посчитайте среднее трёх чисел (например, ваших оценок или любых трёх чисел) одним выражением, используя скобки."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "93ee7ef4",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:52:11.867494Z",
     "iopub.status.busy": "2026-08-14T20:52:11.867383Z",
     "iopub.status.idle": "2026-08-14T20:52:11.869453Z",
     "shell.execute_reply": "2026-08-14T20:52:11.869056Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "9.0\n"
     ]
    }
   ],
   "source": [
    "a, b, c = 8, 9, 10\n",
    "print((a + b + c) / 3)"
   ]
  }
 ],
 "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
}
