{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "a1a3da0a",
   "metadata": {},
   "source": [
    "# 11-01 · Listy: Podstawy\n",
    "\n",
    "Praktyka do rozdziału [„Listy: podstawy”](/pl/chapters/rozdzial-11/11-01-spiski-osnovy.html)."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3faeb110",
   "metadata": {},
   "source": [
    "## Cel\n",
    "\n",
    "Tworzenie list i dostęp do elementów według indeksu."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "202231ea",
   "metadata": {},
   "source": [
    "## Sprawa robocza"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "88951b5b",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-17T14:44:17.029392Z",
     "iopub.status.busy": "2026-08-17T14:44:17.029264Z",
     "iopub.status.idle": "2026-08-17T14:44:17.048774Z",
     "shell.execute_reply": "2026-08-17T14:44:17.048345Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['яблоко', 'банан', 'вишня']\n",
      "яблоко\n",
      "вишня\n"
     ]
    }
   ],
   "source": [
    "fruits = [\"яблоко\", \"банан\", \"вишня\"]\n",
    "print(fruits)\n",
    "print(fruits[0])\n",
    "print(fruits[-1])"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "39136b9c",
   "metadata": {},
   "source": [
    "## Eksperyment 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "b256a438",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-17T14:44:17.049990Z",
     "iopub.status.busy": "2026-08-17T14:44:17.049876Z",
     "iopub.status.idle": "2026-08-17T14:44:17.052288Z",
     "shell.execute_reply": "2026-08-17T14:44:17.051806Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Cartesian <class 'str'>\n",
      "5 <class 'int'>\n",
      "3.14 <class 'float'>\n",
      "True <class 'bool'>\n"
     ]
    }
   ],
   "source": [
    "smeshannyj = [\"Cartesian\", 5, 3.14, True]\n",
    "for item in smeshannyj:\n",
    "    print(item, type(item))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3143673a",
   "metadata": {},
   "source": [
    "## Typowy błąd\n",
    "\n",
    "Indeks spoza listy powoduje IndexError."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "48e88878",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-17T14:44:17.053264Z",
     "iopub.status.busy": "2026-08-17T14:44:17.053159Z",
     "iopub.status.idle": "2026-08-17T14:44:17.078143Z",
     "shell.execute_reply": "2026-08-17T14:44:17.077769Z"
    },
    "tags": [
     "raises-exception"
    ]
   },
   "outputs": [
    {
     "ename": "IndexError",
     "evalue": "list index out of range",
     "output_type": "error",
     "traceback": [
      "\u001b[31m---------------------------------------------------------------------------\u001b[39m",
      "\u001b[31mIndexError\u001b[39m                                Traceback (most recent call last)",
      "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[3]\u001b[39m\u001b[32m, line 2\u001b[39m\n\u001b[32m      1\u001b[39m fruits = [\u001b[33m\"яблоко\"\u001b[39m, \u001b[33m\"банан\"\u001b[39m, \u001b[33m\"вишня\"\u001b[39m]\n\u001b[32m----> \u001b[39m\u001b[32m2\u001b[39m fruits[\u001b[32m10\u001b[39m]\n",
      "\u001b[31mIndexError\u001b[39m: list index out of range"
     ]
    }
   ],
   "source": [
    "fruits = [\"яблоко\", \"банан\", \"вишня\"]\n",
    "fruits[10]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0f4090e4",
   "metadata": {},
   "source": [
    "## Podstawowa praktyka zadań ★\n",
    "\n",
    "Stwórz lista pięciu ulubionych liczb i wypisz pierwszy, ostatni i trzeci od końca."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "43987885",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-17T14:44:17.079430Z",
     "iopub.status.busy": "2026-08-17T14:44:17.079310Z",
     "iopub.status.idle": "2026-08-17T14:44:17.081555Z",
     "shell.execute_reply": "2026-08-17T14:44:17.081168Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "7 100 21\n"
     ]
    }
   ],
   "source": [
    "numbers = [7, 14, 21, 42, 100]\n",
    "print(numbers[0], numbers[-1], numbers[-3])"
   ]
  }
 ],
 "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
}
