{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "a466ad69",
   "metadata": {},
   "source": [
    "# 11-03 · Мощные операции со списками\n",
    "\n",
    "Практика к разделу [«Мощные операции со списками!»](../../site/chapters/glava-11/11-03-operacii-so-spiskami.html)."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "022825f0",
   "metadata": {},
   "source": [
    "## Цель\n",
    "\n",
    "Освоить copy, append, count, clear, конкатенацию, index, insert, remove, pop, sort, reverse."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "89c8532a",
   "metadata": {},
   "source": [
    "## Рабочий пример"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "79933b7e",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:55:38.946160Z",
     "iopub.status.busy": "2026-08-14T20:55:38.946008Z",
     "iopub.status.idle": "2026-08-14T20:55:38.965529Z",
     "shell.execute_reply": "2026-08-14T20:55:38.965017Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1, 2, 3]\n",
      "[1, 2, 3, 4]\n"
     ]
    }
   ],
   "source": [
    "original = [1, 2, 3]\n",
    "kopiya = original.copy()\n",
    "kopiya.append(4)\n",
    "print(original)\n",
    "print(kopiya)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8ae41688",
   "metadata": {},
   "source": [
    "## Эксперимент 1 — почему copy() важен"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "ae7eadd1",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:55:38.966546Z",
     "iopub.status.busy": "2026-08-14T20:55:38.966411Z",
     "iopub.status.idle": "2026-08-14T20:55:38.969421Z",
     "shell.execute_reply": "2026-08-14T20:55:38.968939Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1, 2, 3, 4]\n",
      "[1, 2, 3, 4]\n"
     ]
    }
   ],
   "source": [
    "a = [1, 2, 3]\n",
    "b = a          # НЕ копия — та же ссылка!\n",
    "b.append(4)\n",
    "print(a)        # тоже изменился!\n",
    "print(b)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0858011d",
   "metadata": {},
   "source": [
    "## Эксперимент 2 — добавление и удаление"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "14bccd4e",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:55:38.970354Z",
     "iopub.status.busy": "2026-08-14T20:55:38.970247Z",
     "iopub.status.idle": "2026-08-14T20:55:38.972862Z",
     "shell.execute_reply": "2026-08-14T20:55:38.972420Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['манго', 'яблоко', 'банан', 'вишня']\n",
      "['манго', 'яблоко'] вишня\n"
     ]
    }
   ],
   "source": [
    "fruits = [\"яблоко\", \"банан\"]\n",
    "fruits.append(\"вишня\")\n",
    "fruits.insert(0, \"манго\")\n",
    "print(fruits)\n",
    "\n",
    "fruits.remove(\"банан\")\n",
    "last = fruits.pop()\n",
    "print(fruits, last)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "98896d01",
   "metadata": {},
   "source": [
    "## Задание ★ Базовая практика\n",
    "\n",
    "Отсортируйте список [5, 2, 8, 1, 9] по возрастанию и разверните."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "c323caad",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:55:38.973836Z",
     "iopub.status.busy": "2026-08-14T20:55:38.973728Z",
     "iopub.status.idle": "2026-08-14T20:55:38.976200Z",
     "shell.execute_reply": "2026-08-14T20:55:38.975641Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1, 2, 5, 8, 9]\n",
      "[9, 8, 5, 2, 1]\n"
     ]
    }
   ],
   "source": [
    "numbers = [5, 2, 8, 1, 9]\n",
    "numbers.sort()\n",
    "print(numbers)\n",
    "numbers.reverse()\n",
    "print(numbers)"
   ]
  }
 ],
 "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
}
