{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "3f22612f",
   "metadata": {},
   "source": [
    "# 12-17 · Quiz – Procent poprawnych odpowiedzi\n",
    "\n",
    "Praktyka do sekcji [«Projekt: quiz»](/pl/chapters/rozdzial-12/12-16-viktorina.html#uroven-4)."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3d311ea5",
   "metadata": {},
   "source": [
    "## Cel\n",
    "\n",
    "Poziom 4: Oblicz procent poprawnych odpowiedzi."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2f78c021",
   "metadata": {},
   "source": [
    "## Pro input() w tym laptopie\n",
    "\n",
    "Ten laptop jest automatyczny, więc `input()` tymczasowo zastąpione wcześniej przygotowanymi odpowiedziami."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "a4ea6b12",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-17T16:38:47.285320Z",
     "iopub.status.busy": "2026-08-17T16:38:47.285193Z",
     "iopub.status.idle": "2026-08-17T16:38:47.304823Z",
     "shell.execute_reply": "2026-08-17T16:38:47.304327Z"
    }
   },
   "outputs": [],
   "source": [
    "_answers = iter(['paris', '54', 'python'])\n",
    "\n",
    "def input(prompt=\"\"):\n",
    "    answer = next(_answers)\n",
    "    print(prompt + answer)\n",
    "    return answer"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5306c642",
   "metadata": {},
   "source": [
    "## Zadanie ★★★★ Challenge"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "4a2a496a",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-17T16:38:47.305979Z",
     "iopub.status.busy": "2026-08-17T16:38:47.305861Z",
     "iopub.status.idle": "2026-08-17T16:38:47.308551Z",
     "shell.execute_reply": "2026-08-17T16:38:47.308209Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Столица Франции? paris\n",
      "7 * 8? 54\n",
      "Язык, который мы изучаем? python\n",
      "Результат: 67%\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",
    "        score += 1\n",
    "\n",
    "procent = score / len(questions) * 100\n",
    "print(f\"Результат: {procent:.0f}%\")"
   ]
  }
 ],
 "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
}
