{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "a7e2dc34",
   "metadata": {},
   "source": [
    "# 08-11 · Экранирование\n",
    "\n",
    "Практика к разделу [«Экранирование: \\n, \\t и другие»](../../site/chapters/glava-08/08-11-ekranirovanie.html)."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f8a15af8",
   "metadata": {},
   "source": [
    "## Цель\n",
    "\n",
    "Освоить служебные последовательности \\n, \\t и экранирование кавычек, научиться пользоваться repr() для отладки."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f822a78a",
   "metadata": {},
   "source": [
    "## Рабочий пример"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "4251e42d",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-16T16:18:52.790408Z",
     "iopub.status.busy": "2026-08-16T16:18:52.790299Z",
     "iopub.status.idle": "2026-08-16T16:18:52.809689Z",
     "shell.execute_reply": "2026-08-16T16:18:52.809314Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Первая строка\n",
      "Вторая строка\n",
      "Имя:\tВозраст:\n"
     ]
    }
   ],
   "source": [
    "print(\"Первая строка\\nВторая строка\")\n",
    "print(\"Имя:\\tВозраст:\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "377614b1",
   "metadata": {},
   "source": [
    "## Эксперимент 1 — repr() показывает служебные символы «как в коде»"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "3c0e6f59",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-16T16:18:52.811316Z",
     "iopub.status.busy": "2026-08-16T16:18:52.811170Z",
     "iopub.status.idle": "2026-08-16T16:18:52.814107Z",
     "shell.execute_reply": "2026-08-16T16:18:52.813539Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "a\tb\n",
      "c\n",
      "'a\\tb\\nc'\n"
     ]
    }
   ],
   "source": [
    "text = \"a\\tb\\nc\"\n",
    "print(text)\n",
    "print(repr(text))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e61c9e3c",
   "metadata": {},
   "source": [
    "## Задание ★ Базовая практика\n",
    "\n",
    "Создайте строку `quote` с экранированной двойной кавычкой внутри — «Он сказал: \\\"привет\\\"» — и строку `two_lines` из двух строк текста, разделённых `\\n`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "ec0be3aa",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-16T16:18:52.815380Z",
     "iopub.status.busy": "2026-08-16T16:18:52.815243Z",
     "iopub.status.idle": "2026-08-16T16:18:52.817826Z",
     "shell.execute_reply": "2026-08-16T16:18:52.817258Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Он сказал: \"привет\"\n",
      "Первая\n",
      "Вторая\n"
     ]
    }
   ],
   "source": [
    "quote = \"Он сказал: \\\"привет\\\"\"\n",
    "two_lines = \"Первая\\nВторая\"\n",
    "print(quote)\n",
    "print(two_lines)"
   ]
  }
 ],
 "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
}
