{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "465ba891",
   "metadata": {},
   "source": [
    "# 03-01 · Создание и запуск программ\n",
    "\n",
    "Практика к разделу [«Создание и запуск программ на Python»](../../site/chapters/glava-03/03-01-sozdanie-i-zapusk-programm.html)."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b388f4d2",
   "metadata": {},
   "source": [
    "## Цель\n",
    "\n",
    "Почувствовать, как код превращается в результат — здесь роль «файла и запуска» играет ячейка кода."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3aabc120",
   "metadata": {},
   "source": [
    "## Что нужно знать\n",
    "\n",
    "`print()` выводит текст на экран — знакомая команда из главы 1."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ba514278",
   "metadata": {},
   "source": [
    "## Краткое напоминание\n",
    "\n",
    "В настоящем `.py`-файле код запускают командой `python имя_файла.py`. Здесь для практики каждая ячейка — это как маленькая отдельная программа."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0a560c52",
   "metadata": {},
   "source": [
    "## Рабочий пример"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "c60ba8f1",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:52:10.131031Z",
     "iopub.status.busy": "2026-08-14T20:52:10.130885Z",
     "iopub.status.idle": "2026-08-14T20:52:10.153383Z",
     "shell.execute_reply": "2026-08-14T20:52:10.152927Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Привет, Python!\n"
     ]
    }
   ],
   "source": [
    "print(\"Привет, Python!\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "985f4f27",
   "metadata": {},
   "source": [
    "## Эксперимент 1\n",
    "\n",
    "Измените текст приветствия на своё."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "17f3fd57",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:52:10.154384Z",
     "iopub.status.busy": "2026-08-14T20:52:10.154265Z",
     "iopub.status.idle": "2026-08-14T20:52:10.156380Z",
     "shell.execute_reply": "2026-08-14T20:52:10.155951Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Привет, Cartesian School!\n"
     ]
    }
   ],
   "source": [
    "print(\"Привет, Cartesian School!\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "46ea8c61",
   "metadata": {},
   "source": [
    "## Эксперимент 2\n",
    "\n",
    "Добавьте вторую строку `print()` с вашим именем."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "f5902eb4",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:52:10.157289Z",
     "iopub.status.busy": "2026-08-14T20:52:10.157181Z",
     "iopub.status.idle": "2026-08-14T20:52:10.159775Z",
     "shell.execute_reply": "2026-08-14T20:52:10.158973Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Привет, Python!\n",
      "Меня зовут Cartesian\n"
     ]
    }
   ],
   "source": [
    "print(\"Привет, Python!\")\n",
    "print(\"Меня зовут Cartesian\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "edaba4be",
   "metadata": {},
   "source": [
    "## Типичная ошибка\n",
    "\n",
    "В очень старых учебниках по Python 2 можно встретить `print \"Привет\"` без скобок — в Python 3 (и тем более в 3.14) это ошибка синтаксиса."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "ad1031d2",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:52:10.161145Z",
     "iopub.status.busy": "2026-08-14T20:52:10.161003Z",
     "iopub.status.idle": "2026-08-14T20:52:10.163553Z",
     "shell.execute_reply": "2026-08-14T20:52:10.163078Z"
    },
    "tags": [
     "raises-exception"
    ]
   },
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "Missing parentheses in call to 'print'. Did you mean print(...)? (1407130998.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 \"Привет\"\u001b[39m\n    ^\n\u001b[31mSyntaxError\u001b[39m\u001b[31m:\u001b[39m Missing parentheses in call to 'print'. Did you mean print(...)?\n"
     ]
    }
   ],
   "source": [
    "print \"Привет\""
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a77199a0",
   "metadata": {},
   "source": [
    "## Исправление\n",
    "\n",
    "В Python 3 `print` — обычная функция, аргумент передают в скобках."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "491d9a4e",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:52:10.164614Z",
     "iopub.status.busy": "2026-08-14T20:52:10.164508Z",
     "iopub.status.idle": "2026-08-14T20:52:10.166535Z",
     "shell.execute_reply": "2026-08-14T20:52:10.166128Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Привет\n"
     ]
    }
   ],
   "source": [
    "print(\"Привет\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "672df4c2",
   "metadata": {},
   "source": [
    "## Задание ★ Базовая практика\n",
    "\n",
    "Выведите три строки: своё имя, свой город и любимое число."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "d683ef5a",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:52:10.167459Z",
     "iopub.status.busy": "2026-08-14T20:52:10.167344Z",
     "iopub.status.idle": "2026-08-14T20:52:10.169518Z",
     "shell.execute_reply": "2026-08-14T20:52:10.169001Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Cartesian\n",
      "Москва\n",
      "42\n"
     ]
    }
   ],
   "source": [
    "print(\"Cartesian\")\n",
    "print(\"Москва\")\n",
    "print(42)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "db323c61",
   "metadata": {},
   "source": [
    "## Самостоятельная практика ★★\n",
    "\n",
    "Выведите небольшое двустишие или цитату — минимум две строки — используя два отдельных вызова `print()`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "e6349230",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:52:10.170468Z",
     "iopub.status.busy": "2026-08-14T20:52:10.170360Z",
     "iopub.status.idle": "2026-08-14T20:52:10.172606Z",
     "shell.execute_reply": "2026-08-14T20:52:10.172234Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Код за кодом, шаг за шагом —\n",
      "так рождается программа.\n"
     ]
    }
   ],
   "source": [
    "print(\"Код за кодом, шаг за шагом —\")\n",
    "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
}
