{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "396fca76",
   "metadata": {},
   "source": [
    "# 04-01 · Числа и переменные\n",
    "\n",
    "Практика к разделу [«Числа в Python, сохраняем числа»](../../site/chapters/glava-04/04-01-chisla-i-peremennye.html)."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ad12ac77",
   "metadata": {},
   "source": [
    "## Цель\n",
    "\n",
    "Научиться сохранять числа в переменные и правильно их называть."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "53c602e5",
   "metadata": {},
   "source": [
    "## Что нужно знать\n",
    "\n",
    "`print()` — уже знакомая команда из глав 1 и 3."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c77b7e8f",
   "metadata": {},
   "source": [
    "## Краткое напоминание\n",
    "\n",
    "Имя переменной — буквы, цифры, `_`; не начинается с цифры; стиль — `snake_case`."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ae28ce4e",
   "metadata": {},
   "source": [
    "## Рабочий пример"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "67dc314b",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:52:13.506478Z",
     "iopub.status.busy": "2026-08-14T20:52:13.506331Z",
     "iopub.status.idle": "2026-08-14T20:52:13.521569Z",
     "shell.execute_reply": "2026-08-14T20:52:13.521111Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "10\n",
      "11\n"
     ]
    }
   ],
   "source": [
    "age = 10\n",
    "print(age)\n",
    "\n",
    "age = 11  # значение можно заменить\n",
    "print(age)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a9060ea8",
   "metadata": {},
   "source": [
    "## Эксперимент 1\n",
    "\n",
    "Создайте переменную `city` со своим городом и выведите её."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "ff97e1b5",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:52:13.522603Z",
     "iopub.status.busy": "2026-08-14T20:52:13.522486Z",
     "iopub.status.idle": "2026-08-14T20:52:13.524849Z",
     "shell.execute_reply": "2026-08-14T20:52:13.524259Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Москва\n"
     ]
    }
   ],
   "source": [
    "city = \"Москва\"\n",
    "print(city)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c4ddf420",
   "metadata": {},
   "source": [
    "## Эксперимент 2\n",
    "\n",
    "Создайте две переменные и выведите их сумму."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "d5e2e3fd",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:52:13.525861Z",
     "iopub.status.busy": "2026-08-14T20:52:13.525749Z",
     "iopub.status.idle": "2026-08-14T20:52:13.527904Z",
     "shell.execute_reply": "2026-08-14T20:52:13.527455Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "12\n"
     ]
    }
   ],
   "source": [
    "a = 5\n",
    "b = 7\n",
    "print(a + b)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9471cc4c",
   "metadata": {},
   "source": [
    "## Типичная ошибка\n",
    "\n",
    "Имя переменной не может начинаться с цифры."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "289381a4",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:52:13.528874Z",
     "iopub.status.busy": "2026-08-14T20:52:13.528760Z",
     "iopub.status.idle": "2026-08-14T20:52:13.531391Z",
     "shell.execute_reply": "2026-08-14T20:52:13.530958Z"
    },
    "tags": [
     "raises-exception"
    ]
   },
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "invalid decimal literal (2968492806.py, line 1)",
     "output_type": "error",
     "traceback": [
      "  \u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[4]\u001b[39m\u001b[32m, line 1\u001b[39m\n\u001b[31m    \u001b[39m\u001b[31m1_place = \"Cartesian\"\u001b[39m\n     ^\n\u001b[31mSyntaxError\u001b[39m\u001b[31m:\u001b[39m invalid decimal literal\n"
     ]
    }
   ],
   "source": [
    "1_place = \"Cartesian\""
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9c94df17",
   "metadata": {},
   "source": [
    "## Исправление"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "d08a362c",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:52:13.532328Z",
     "iopub.status.busy": "2026-08-14T20:52:13.532230Z",
     "iopub.status.idle": "2026-08-14T20:52:13.534541Z",
     "shell.execute_reply": "2026-08-14T20:52:13.533827Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Cartesian\n"
     ]
    }
   ],
   "source": [
    "place_1 = \"Cartesian\"\n",
    "print(place_1)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5ddfc106",
   "metadata": {},
   "source": [
    "## Задание ★ Базовая практика\n",
    "\n",
    "Создайте переменные `name`, `age`, `city` со своими данными и выведите их одной командой `print()` через запятую."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "f90e0202",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:52:13.535547Z",
     "iopub.status.busy": "2026-08-14T20:52:13.535437Z",
     "iopub.status.idle": "2026-08-14T20:52:13.537665Z",
     "shell.execute_reply": "2026-08-14T20:52:13.537258Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Cartesian 5 Москва\n"
     ]
    }
   ],
   "source": [
    "name = \"Cartesian\"\n",
    "age = 5\n",
    "city = \"Москва\"\n",
    "print(name, age, city)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a192f1d9",
   "metadata": {},
   "source": [
    "## Самостоятельная практика ★★\n",
    "\n",
    "Посчитайте, сколько дней в `age` годах (приблизительно, 365 дней в году), сохранив результат в новую переменную `days`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "df8d2c3a",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:52:13.538583Z",
     "iopub.status.busy": "2026-08-14T20:52:13.538484Z",
     "iopub.status.idle": "2026-08-14T20:52:13.540598Z",
     "shell.execute_reply": "2026-08-14T20:52:13.540196Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "4380\n"
     ]
    }
   ],
   "source": [
    "age = 12\n",
    "days = age * 365\n",
    "print(days)"
   ]
  }
 ],
 "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
}
