{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "1c4e171d",
   "metadata": {},
   "source": [
    "# 03-04 · Вывод данных с помощью Python\n",
    "\n",
    "Практика к разделу [«Вывод данных с помощью Python»](../../site/chapters/glava-03/03-03-vyvod-dannyh.html)."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5e1e0a59",
   "metadata": {},
   "source": [
    "## Цель\n",
    "\n",
    "Освоить `print()` подробно: несколько значений, `sep`, `end`."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "91581db1",
   "metadata": {},
   "source": [
    "## Что нужно знать\n",
    "\n",
    "`print()` умеет выводить несколько значений через запятую."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d3005581",
   "metadata": {},
   "source": [
    "## Краткое напоминание\n",
    "\n",
    "- по умолчанию значения разделяются пробелом;\n",
    "- `sep=\"...\"` меняет разделитель;\n",
    "- `end=\"...\"` меняет символ в конце (по умолчанию — перевод строки)."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "833b8274",
   "metadata": {},
   "source": [
    "## Рабочий пример"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "3087d89d",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:52:12.684969Z",
     "iopub.status.busy": "2026-08-14T20:52:12.684853Z",
     "iopub.status.idle": "2026-08-14T20:52:12.701406Z",
     "shell.execute_reply": "2026-08-14T20:52:12.700969Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Возраст: 10 лет\n"
     ]
    }
   ],
   "source": [
    "print(\"Возраст:\", 10, \"лет\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "fbf459fc",
   "metadata": {},
   "source": [
    "## Эксперимент 1\n",
    "\n",
    "Измените разделитель на дефис."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "ac99e57d",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:52:12.702404Z",
     "iopub.status.busy": "2026-08-14T20:52:12.702290Z",
     "iopub.status.idle": "2026-08-14T20:52:12.704461Z",
     "shell.execute_reply": "2026-08-14T20:52:12.704069Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2024-01-15\n"
     ]
    }
   ],
   "source": [
    "print(\"2024\", \"01\", \"15\", sep=\"-\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ac5bfeca",
   "metadata": {},
   "source": [
    "## Эксперимент 2\n",
    "\n",
    "Используйте `end=\"\"`, чтобы два вызова `print()` вывелись в одну строку без переноса."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "4929f485",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:52:12.705428Z",
     "iopub.status.busy": "2026-08-14T20:52:12.705325Z",
     "iopub.status.idle": "2026-08-14T20:52:12.707617Z",
     "shell.execute_reply": "2026-08-14T20:52:12.707205Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Загрузка...готово!\n"
     ]
    }
   ],
   "source": [
    "print(\"Загрузка\", end=\"\")\n",
    "print(\"...\", end=\"\")\n",
    "print(\"готово!\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b5fff76d",
   "metadata": {},
   "source": [
    "## Задание ★ Базовая практика (и практика главы: «выведите своё имя»)\n",
    "\n",
    "Одной командой `print()` с `sep=\" · \"` выведите своё имя, город и любимое число."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "354be90d",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:52:12.708690Z",
     "iopub.status.busy": "2026-08-14T20:52:12.708560Z",
     "iopub.status.idle": "2026-08-14T20:52:12.711138Z",
     "shell.execute_reply": "2026-08-14T20:52:12.710688Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Cartesian · Москва · 42\n"
     ]
    }
   ],
   "source": [
    "print(\"Cartesian\", \"Москва\", 42, sep=\" · \")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b04af67a",
   "metadata": {},
   "source": [
    "## Типичная ошибка\n",
    "\n",
    "`sep` и `end` — именованные параметры: их нужно передавать по имени. Если перепутать порядок и передать их как обычные значения, они попадут в сам вывод, а не станут разделителем."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "a29beb92",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:52:12.712147Z",
     "iopub.status.busy": "2026-08-14T20:52:12.712030Z",
     "iopub.status.idle": "2026-08-14T20:52:12.714182Z",
     "shell.execute_reply": "2026-08-14T20:52:12.713720Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "a b -\n"
     ]
    }
   ],
   "source": [
    "print(\"a\", \"b\", \"-\")  # это НЕ то же самое, что sep=\"-\""
   ]
  },
  {
   "cell_type": "markdown",
   "id": "251169c1",
   "metadata": {},
   "source": [
    "## Исправление"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "e28daecc",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:52:12.715154Z",
     "iopub.status.busy": "2026-08-14T20:52:12.715052Z",
     "iopub.status.idle": "2026-08-14T20:52:12.717221Z",
     "shell.execute_reply": "2026-08-14T20:52:12.716822Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "a-b\n"
     ]
    }
   ],
   "source": [
    "print(\"a\", \"b\", sep=\"-\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "18a710f7",
   "metadata": {},
   "source": [
    "## Самостоятельная практика ★★\n",
    "\n",
    "Выведите таблицу из трёх строк вида `имя — оценка`, используя `sep=\" — \"` в каждом вызове."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "5e3714e2",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:52:12.718175Z",
     "iopub.status.busy": "2026-08-14T20:52:12.718073Z",
     "iopub.status.idle": "2026-08-14T20:52:12.720440Z",
     "shell.execute_reply": "2026-08-14T20:52:12.720029Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Математика — 5\n",
      "Python — 5\n",
      "Физика — 4\n"
     ]
    }
   ],
   "source": [
    "print(\"Математика\", 5, sep=\" — \")\n",
    "print(\"Python\", 5, sep=\" — \")\n",
    "print(\"Физика\", 4, sep=\" — \")"
   ]
  }
 ],
 "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
}
