{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "a4d57d2c",
   "metadata": {},
   "source": [
    "# 13-14 · Keyword-only параметры\n",
    "\n",
    "Практика к разделу [«Positional-only и keyword-only»](../../site/chapters/glava-13/13-14-positional-only-keyword-only.html)."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "74bc1416",
   "metadata": {},
   "source": [
    "## Цель\n",
    "\n",
    "Создать функцию с keyword-only параметром и проверить, что позиционный вызов для него запрещён."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e9289f22",
   "metadata": {},
   "source": [
    "## Задание ★ Базовая практика"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "4180b4fa",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-17T18:53:59.268708Z",
     "iopub.status.busy": "2026-08-17T18:53:59.268590Z",
     "iopub.status.idle": "2026-08-17T18:53:59.292947Z",
     "shell.execute_reply": "2026-08-17T18:53:59.292525Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "10x20 blue 10x20 red True\n"
     ]
    }
   ],
   "source": [
    "def draw_rectangle(width, height, *, color=\"blue\"):\n",
    "    return f\"{width}x{height} {color}\"\n",
    "\n",
    "r1 = draw_rectangle(10, 20)\n",
    "r2 = draw_rectangle(10, 20, color=\"red\")\n",
    "\n",
    "try:\n",
    "    draw_rectangle(10, 20, \"red\")\n",
    "    keyword_only_enforced = False\n",
    "except TypeError:\n",
    "    keyword_only_enforced = True\n",
    "\n",
    "print(r1, r2, keyword_only_enforced)"
   ]
  }
 ],
 "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
}
