{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "16f957b0",
   "metadata": {},
   "source": [
    "# 08-09 · Крик и переворот имени\n",
    "\n",
    "Практика к разделу [«Мини-проекты: крик и переворот имени»](../../site/chapters/glava-08/08-09-mini-proekty-krik-perevorot.html)."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c45fe09c",
   "metadata": {},
   "source": [
    "## Цель\n",
    "\n",
    "Применить upper() и срез [::-1] в двух коротких мини-проектах."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d64bdd75",
   "metadata": {},
   "source": [
    "## Про input() в этом ноутбуке\n",
    "\n",
    "В обычном `.py`-файле `input()` ждёт, пока вы наберёте текст и нажмёте Enter. Этот ноутбук выполняется автоматически, без живого человека за клавиатурой — поэтому здесь `input()` временно подменён на заранее заготовленные ответы. Сам код с `input()` ниже выглядит и работает точно так же, как в обычном файле, который вы запускаете сами."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "7722fe4d",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:53:50.734468Z",
     "iopub.status.busy": "2026-08-14T20:53:50.734363Z",
     "iopub.status.idle": "2026-08-14T20:53:50.753190Z",
     "shell.execute_reply": "2026-08-14T20:53:50.752814Z"
    }
   },
   "outputs": [],
   "source": [
    "_answers = iter(['python это круто', 'Cartesian', 'довод', 'Python'])\n",
    "\n",
    "def input(prompt=\"\"):\n",
    "    answer = next(_answers)\n",
    "    print(prompt + answer)\n",
    "    return answer"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "95b9036a",
   "metadata": {},
   "source": [
    "## Рабочий пример — кричим на экран"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "b468b3d2",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:53:50.754534Z",
     "iopub.status.busy": "2026-08-14T20:53:50.754411Z",
     "iopub.status.idle": "2026-08-14T20:53:50.756914Z",
     "shell.execute_reply": "2026-08-14T20:53:50.756457Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Что вы хотите прокричать? python это круто\n",
      "PYTHON ЭТО КРУТО!!!\n"
     ]
    }
   ],
   "source": [
    "phrase = input(\"Что вы хотите прокричать? \")\n",
    "krik = phrase.upper() + \"!!!\"\n",
    "print(krik)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c6161929",
   "metadata": {},
   "source": [
    "## Рабочий пример — переворот имени"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "b4067a39",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:53:50.758011Z",
     "iopub.status.busy": "2026-08-14T20:53:50.757846Z",
     "iopub.status.idle": "2026-08-14T20:53:50.760531Z",
     "shell.execute_reply": "2026-08-14T20:53:50.760036Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Как вас зовут? Cartesian\n",
      "Ваше имя задом наперёд: naisetraC\n"
     ]
    }
   ],
   "source": [
    "name = input(\"Как вас зовут? \")\n",
    "perevernutoe = name[::-1]\n",
    "print(f\"Ваше имя задом наперёд: {perevernutoe}\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "cb83c410",
   "metadata": {},
   "source": [
    "## Задание ★★ Самостоятельная задача — палиндром?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "ad9ae818",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:53:50.761840Z",
     "iopub.status.busy": "2026-08-14T20:53:50.761713Z",
     "iopub.status.idle": "2026-08-14T20:53:50.764354Z",
     "shell.execute_reply": "2026-08-14T20:53:50.763887Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Введите слово: довод\n",
      "«довод» — палиндром: True\n"
     ]
    }
   ],
   "source": [
    "word = input(\"Введите слово: \")\n",
    "is_palindrome = word.lower() == word.lower()[::-1]\n",
    "print(f\"«{word}» — палиндром: {is_palindrome}\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1fb0f396",
   "metadata": {},
   "source": [
    "## Проверка результата"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "a824784d",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:53:50.765334Z",
     "iopub.status.busy": "2026-08-14T20:53:50.765228Z",
     "iopub.status.idle": "2026-08-14T20:53:50.767553Z",
     "shell.execute_reply": "2026-08-14T20:53:50.767085Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Введите слово: Python\n",
      "False\n"
     ]
    }
   ],
   "source": [
    "word = input(\"Введите слово: \")\n",
    "print(word.lower() == word.lower()[::-1])"
   ]
  }
 ],
 "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
}
