{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "2d39e177",
   "metadata": {},
   "source": [
    "# 19-16 · Голова, тело и модель Snake\n",
    "\n",
    "Практика к разделу [«Голова, тело и модель Snake»](../../site/chapters/glava-19/19-16-model-snake.html)."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5e509fa5",
   "metadata": {},
   "source": [
    "## Цель\n",
    "\n",
    "Змейка — список позиций; snake[0] всегда голова."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e71dcded",
   "metadata": {},
   "source": [
    "## Рабочий пример"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "a49f22e4",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-09-03T00:53:55.101595Z",
     "iopub.status.busy": "2026-09-03T00:53:55.101417Z",
     "iopub.status.idle": "2026-09-03T00:53:55.130793Z",
     "shell.execute_reply": "2026-09-03T00:53:55.130142Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(0, 0) [(-20, 0), (-40, 0)]\n"
     ]
    }
   ],
   "source": [
    "snake = [(0, 0), (-20, 0), (-40, 0)]\n",
    "\n",
    "def head_of(snake):\n",
    "    return snake[0]\n",
    "\n",
    "def body_of(snake):\n",
    "    return snake[1:]\n",
    "\n",
    "print(head_of(snake), body_of(snake))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5c651aca",
   "metadata": {},
   "source": [
    "## Задание ★ Базовая практика"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "4de11c1c",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-09-03T00:53:55.132101Z",
     "iopub.status.busy": "2026-09-03T00:53:55.131930Z",
     "iopub.status.idle": "2026-09-03T00:53:55.137616Z",
     "shell.execute_reply": "2026-09-03T00:53:55.137122Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Модель змейки — обычный список координат.\n"
     ]
    }
   ],
   "source": [
    "assert head_of(snake) == (0, 0)\n",
    "assert body_of(snake) == [(-20, 0), (-40, 0)]\n",
    "assert len(snake) == 3\n",
    "print(\"Модель змейки — обычный список координат.\")"
   ]
  }
 ],
 "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
}
