{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "97c00980",
   "metadata": {},
   "source": [
    "# 12-16 · Викторина\n",
    "\n",
    "Практика к разделу [«Проект: викторина»](../../site/chapters/glava-12/12-16-viktorina.html)."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "55d37200",
   "metadata": {},
   "source": [
    "## Цель\n",
    "\n",
    "Данные (список вопросов) + один алгоритм (цикл), а не захардкоженная логика."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "46c0c5e2",
   "metadata": {},
   "source": [
    "## Про input() в этом ноутбуке\n",
    "\n",
    "Этот ноутбук выполняется автоматически, поэтому `input()` временно подменён на заранее заготовленные ответы."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "ddb5c0dc",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-17T16:38:45.337989Z",
     "iopub.status.busy": "2026-08-17T16:38:45.337889Z",
     "iopub.status.idle": "2026-08-17T16:38:45.377129Z",
     "shell.execute_reply": "2026-08-17T16:38:45.376238Z"
    }
   },
   "outputs": [],
   "source": [
    "_answers = iter(['paris', '56', 'python'])\n",
    "\n",
    "def input(prompt=\"\"):\n",
    "    answer = next(_answers)\n",
    "    print(prompt + answer)\n",
    "    return answer"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6db48c73",
   "metadata": {},
   "source": [
    "## Рабочий пример"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "8cf3d5e1",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-17T16:38:45.378571Z",
     "iopub.status.busy": "2026-08-17T16:38:45.378369Z",
     "iopub.status.idle": "2026-08-17T16:38:45.382253Z",
     "shell.execute_reply": "2026-08-17T16:38:45.381744Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Столица Франции? paris\n",
      "✅ Верно!\n",
      "7 * 8? 56\n",
      "✅ Верно!\n",
      "Язык, который мы изучаем? python\n",
      "✅ Верно!\n",
      "Счёт: 3 из 3\n"
     ]
    }
   ],
   "source": [
    "questions = [\n",
    "    {\"question\": \"Столица Франции?\", \"answer\": \"paris\"},\n",
    "    {\"question\": \"7 * 8?\", \"answer\": \"56\"},\n",
    "    {\"question\": \"Язык, который мы изучаем?\", \"answer\": \"python\"},\n",
    "]\n",
    "\n",
    "score = 0\n",
    "for q in questions:\n",
    "    user_answer = input(q[\"question\"] + \" \").strip().lower()\n",
    "    if user_answer == q[\"answer\"]:\n",
    "        print(\"✅ Верно!\")\n",
    "        score += 1\n",
    "    else:\n",
    "        print(f\"❌ Неверно. Правильный ответ: {q['answer']}\")\n",
    "\n",
    "print(f\"Счёт: {score} из {len(questions)}\")"
   ]
  }
 ],
 "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
}
