{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "fffd4bc6",
   "metadata": {},
   "source": [
    "# 03-09 · Прочитайте traceback: SyntaxError\n",
    "\n",
    "Практика к разделу [«Типичные проблемы и отладка»](../../site/chapters/glava-03/03-14-debug-laboratorii.html)."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "83366838",
   "metadata": {},
   "source": [
    "## Цель\n",
    "\n",
    "Научиться находить пропущенную скобку или кавычку по сообщению `SyntaxError`."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "eccd8d58",
   "metadata": {},
   "source": [
    "## Что нужно знать\n",
    "\n",
    "`SyntaxError` означает: Python не смог даже понять структуру кода — до выполнения дело не дошло вовсе."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "62ca0026",
   "metadata": {},
   "source": [
    "## Краткое напоминание\n",
    "\n",
    "`SyntaxError` часто указывает не на саму проблемную скобку/кавычку, а на место, где Python «сдался» — иногда это следующая строка. Полезно перечитать всю строку целиком, а не только указанный символ."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1ad3b18a",
   "metadata": {},
   "source": [
    "## Разминка\n",
    "\n",
    "Прежде чем смотреть на ошибку, запустите одну рабочую ячейку — чтобы Python-среда точно была готова."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "17f6df85",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-16T02:04:23.923419Z",
     "iopub.status.busy": "2026-08-16T02:04:23.923288Z",
     "iopub.status.idle": "2026-08-16T02:04:23.957252Z",
     "shell.execute_reply": "2026-08-16T02:04:23.956896Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Готовы искать ошибки!\n"
     ]
    }
   ],
   "source": [
    "print(\"Готовы искать ошибки!\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "aaf49d17",
   "metadata": {},
   "source": [
    "## Рабочий пример\n",
    "\n",
    "Здесь не хватает закрывающей скобки."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "4a0010a3",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-16T02:04:23.958472Z",
     "iopub.status.busy": "2026-08-16T02:04:23.958361Z",
     "iopub.status.idle": "2026-08-16T02:04:23.960946Z",
     "shell.execute_reply": "2026-08-16T02:04:23.960463Z"
    },
    "tags": [
     "raises-exception"
    ]
   },
   "outputs": [
    {
     "ename": "_IncompleteInputError",
     "evalue": "incomplete input (1540670067.py, line 1)",
     "output_type": "error",
     "traceback": [
      "  \u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[2]\u001b[39m\u001b[32m, line 1\u001b[39m\n\u001b[31m    \u001b[39m\u001b[31mprint(\"Привет, Python!\"\u001b[39m\n                           ^\n\u001b[31m_IncompleteInputError\u001b[39m\u001b[31m:\u001b[39m incomplete input\n"
     ]
    }
   ],
   "source": [
    "print(\"Привет, Python!\""
   ]
  },
  {
   "cell_type": "markdown",
   "id": "293ba38d",
   "metadata": {},
   "source": [
    "## Исправление"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "f680f058",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-16T02:04:23.961908Z",
     "iopub.status.busy": "2026-08-16T02:04:23.961799Z",
     "iopub.status.idle": "2026-08-16T02:04:23.963833Z",
     "shell.execute_reply": "2026-08-16T02:04:23.963463Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Привет, Python!\n"
     ]
    }
   ],
   "source": [
    "print(\"Привет, Python!\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c0bbc48d",
   "metadata": {},
   "source": [
    "## Эксперимент 1\n",
    "\n",
    "А здесь не хватает закрывающей кавычки. Найдите и исправьте."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "5d817d75",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-16T02:04:23.964816Z",
     "iopub.status.busy": "2026-08-16T02:04:23.964715Z",
     "iopub.status.idle": "2026-08-16T02:04:23.967025Z",
     "shell.execute_reply": "2026-08-16T02:04:23.966581Z"
    },
    "tags": [
     "raises-exception"
    ]
   },
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "unterminated string literal (detected at line 1) (1195626594.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[31mprint(\"Привет, Python!)\u001b[39m\n          ^\n\u001b[31mSyntaxError\u001b[39m\u001b[31m:\u001b[39m unterminated string literal (detected at line 1)\n"
     ]
    }
   ],
   "source": [
    "print(\"Привет, Python!)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "18139f3e",
   "metadata": {},
   "source": [
    "## Решение эксперимента 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "f4585b80",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-16T02:04:23.967943Z",
     "iopub.status.busy": "2026-08-16T02:04:23.967836Z",
     "iopub.status.idle": "2026-08-16T02:04:23.969823Z",
     "shell.execute_reply": "2026-08-16T02:04:23.969412Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Привет, Python!\n"
     ]
    }
   ],
   "source": [
    "print(\"Привет, Python!\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0f6f7a8b",
   "metadata": {},
   "source": [
    "## Задание ★ Базовая практика\n",
    "\n",
    "Исправьте обе ошибки в строке ниже — недостающую скобку И недостающую кавычку — и запустите без ошибок."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "b7a46003",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-16T02:04:23.970741Z",
     "iopub.status.busy": "2026-08-16T02:04:23.970584Z",
     "iopub.status.idle": "2026-08-16T02:04:23.972799Z",
     "shell.execute_reply": "2026-08-16T02:04:23.972441Z"
    },
    "tags": [
     "raises-exception"
    ]
   },
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "unterminated string literal (detected at line 1) (1350391576.py, line 1)",
     "output_type": "error",
     "traceback": [
      "  \u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[6]\u001b[39m\u001b[32m, line 1\u001b[39m\n\u001b[31m    \u001b[39m\u001b[31mprint(\"Готово!\u001b[39m\n          ^\n\u001b[31mSyntaxError\u001b[39m\u001b[31m:\u001b[39m unterminated string literal (detected at line 1)\n"
     ]
    }
   ],
   "source": [
    "print(\"Готово!"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6ff3ff5b",
   "metadata": {},
   "source": [
    "## Решение задания"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "980acbcc",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-16T02:04:23.973813Z",
     "iopub.status.busy": "2026-08-16T02:04:23.973622Z",
     "iopub.status.idle": "2026-08-16T02:04:23.975695Z",
     "shell.execute_reply": "2026-08-16T02:04:23.975336Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Готово!\n"
     ]
    }
   ],
   "source": [
    "print(\"Готово!\")"
   ]
  }
 ],
 "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
}
