{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "f5fd12f2",
   "metadata": {},
   "source": [
    "# 12-18 · Konsola poleceń\n",
    "\n",
    "Praktyka do [„Projects: Command Console and Password Check”"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6f27ad93",
   "metadata": {},
   "source": [
    "## Cel\n",
    "\n",
    "while True + if/elif/else + break to wzór występujący w menu, konsolach i botach."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e5edd5f6",
   "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": "a3d8231a",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-17T16:38:49.219182Z",
     "iopub.status.busy": "2026-08-17T16:38:49.219065Z",
     "iopub.status.idle": "2026-08-17T16:38:49.236317Z",
     "shell.execute_reply": "2026-08-17T16:38:49.236008Z"
    }
   },
   "outputs": [],
   "source": [
    "_answers = iter(['help', 'hello', 'status', 'exit'])\n",
    "\n",
    "def input(prompt=\"\"):\n",
    "    answer = next(_answers)\n",
    "    print(prompt + answer)\n",
    "    return answer"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "719bb64d",
   "metadata": {},
   "source": [
    "## Sprawa robocza"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "e44060bf",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-17T16:38:49.237740Z",
     "iopub.status.busy": "2026-08-17T16:38:49.237624Z",
     "iopub.status.idle": "2026-08-17T16:38:49.240494Z",
     "shell.execute_reply": "2026-08-17T16:38:49.240126Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "> help\n",
      "Команды: help, hello, status, exit\n",
      "> hello\n",
      "Привет!\n",
      "> status\n",
      "Команд выполнено: 3\n",
      "> exit\n",
      "До встречи!\n",
      "['help', 'hello', 'status', 'exit']\n"
     ]
    }
   ],
   "source": [
    "history = []\n",
    "\n",
    "while True:\n",
    "    command = input(\"> \").strip().lower()\n",
    "    history.append(command)\n",
    "\n",
    "    if command == \"exit\":\n",
    "        print(\"До встречи!\")\n",
    "        break\n",
    "    elif command == \"help\":\n",
    "        print(\"Команды: help, hello, status, exit\")\n",
    "    elif command == \"hello\":\n",
    "        print(\"Привет!\")\n",
    "    elif command == \"status\":\n",
    "        print(f\"Команд выполнено: {len(history)}\")\n",
    "    else:\n",
    "        print(f\"Неизвестная команда: {command}\")\n",
    "\n",
    "print(history)"
   ]
  }
 ],
 "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
}
