{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "94acdb5e",
   "metadata": {},
   "source": [
    "# 11-04 · Ещё больше о списках\n",
    "\n",
    "Практика к разделу [«Ещё больше интересного со списками!»](../../site/chapters/glava-11/11-04-eshche-o-spiskah.html)."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "574008ec",
   "metadata": {},
   "source": [
    "## Цель\n",
    "\n",
    "Освоить len/min/max/sum, вложенные списки и list comprehension."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4906580d",
   "metadata": {},
   "source": [
    "## Рабочий пример"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "a4db6602",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:55:39.734617Z",
     "iopub.status.busy": "2026-08-14T20:55:39.734444Z",
     "iopub.status.idle": "2026-08-14T20:55:39.753666Z",
     "shell.execute_reply": "2026-08-14T20:55:39.753221Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "6 4 42 108\n"
     ]
    }
   ],
   "source": [
    "chisla = [4, 8, 15, 16, 23, 42]\n",
    "print(len(chisla), min(chisla), max(chisla), sum(chisla))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d6a5cca8",
   "metadata": {},
   "source": [
    "## Эксперимент 1 — вложенные списки"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "efcd37aa",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:55:39.754943Z",
     "iopub.status.busy": "2026-08-14T20:55:39.754793Z",
     "iopub.status.idle": "2026-08-14T20:55:39.757278Z",
     "shell.execute_reply": "2026-08-14T20:55:39.756775Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1, 2, 3]\n",
      "2\n",
      "6\n"
     ]
    }
   ],
   "source": [
    "matrix = [[1, 2, 3], [4, 5, 6]]\n",
    "print(matrix[0])\n",
    "print(matrix[0][1])\n",
    "print(matrix[1][2])"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8487e897",
   "metadata": {},
   "source": [
    "## Эксперимент 2 — list comprehension"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "cd5b1720",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:55:39.758159Z",
     "iopub.status.busy": "2026-08-14T20:55:39.758057Z",
     "iopub.status.idle": "2026-08-14T20:55:39.760917Z",
     "shell.execute_reply": "2026-08-14T20:55:39.760360Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1, 4, 9, 16, 25]\n",
      "[2, 4, 6, 8, 10, 12, 14, 16, 18]\n"
     ]
    }
   ],
   "source": [
    "kvadraty = [n ** 2 for n in range(1, 6)]\n",
    "print(kvadraty)\n",
    "\n",
    "chetnye = [n for n in range(1, 20) if n % 2 == 0]\n",
    "print(chetnye)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a3615e84",
   "metadata": {},
   "source": [
    "## Задание ★ Базовая практика\n",
    "\n",
    "Постройте список кубов чисел от 1 до 10 двумя способами: циклом с append() и генератором списков."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "bc65be7f",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:55:39.762119Z",
     "iopub.status.busy": "2026-08-14T20:55:39.761999Z",
     "iopub.status.idle": "2026-08-14T20:55:39.764611Z",
     "shell.execute_reply": "2026-08-14T20:55:39.764209Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1, 8, 27, 64, 125, 216, 343, 512, 729, 1000]\n",
      "True\n"
     ]
    }
   ],
   "source": [
    "kuby_v1 = []\n",
    "for n in range(1, 11):\n",
    "    kuby_v1.append(n ** 3)\n",
    "\n",
    "kuby_v2 = [n ** 3 for n in range(1, 11)]\n",
    "\n",
    "print(kuby_v1)\n",
    "print(kuby_v1 == kuby_v2)"
   ]
  }
 ],
 "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
}
