{ "cells": [ { "cell_type": "markdown", "id": "6aa3b03bcf7b953c", "metadata": {}, "source": [ "# Složené datové typy\n", "## Seznam" ] }, { "cell_type": "code", "execution_count": 2, "id": "cb1744c394fa4568", "metadata": { "ExecuteTime": { "end_time": "2026-02-13T10:14:08.001260227Z", "start_time": "2026-02-13T10:14:07.660345478Z" } }, "outputs": [], "source": [ "znamky = [1, 2, 1, 3, 1, 5, 2, 4, 1]" ] }, { "cell_type": "markdown", "id": "3384178d3a6353ea", "metadata": {}, "source": [ "### 1. Vypište seznam známek" ] }, { "cell_type": "code", "execution_count": 3, "id": "438626158f687df3", "metadata": { "ExecuteTime": { "end_time": "2026-02-13T10:25:56.143800042Z", "start_time": "2026-02-13T10:25:55.941364638Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[1, 2, 1, 3, 1, 5, 2, 4, 1]\n", "1\n", "2\n", "1\n", "3\n", "1\n", "5\n", "2\n", "4\n", "1\n", "---\n", "0 1\n", "1 2\n", "2 1\n", "3 3\n", "4 1\n", "5 5\n", "6 2\n", "7 4\n", "8 1\n", "---\n", "0 1\n", "1 2\n", "2 1\n", "3 3\n", "4 1\n", "5 5\n", "6 2\n", "7 4\n", "8 1\n" ] } ], "source": [ "print(znamky)\n", "\n", "for znamka in znamky:\n", " print(znamka)\n", "\n", "print(\"---\")\n", "\n", "delka = len(znamky)\n", "pozice = 0\n", "\n", "while pozice < delka:\n", " print(pozice, znamky[pozice])\n", " pozice += 1\n", "\n", "print(\"---\")\n", "for poloha in range(delka):\n", " print(poloha, znamky[poloha])\n" ] }, { "cell_type": "markdown", "id": "2dd595a1c2ed5767", "metadata": {}, "source": [ "### 2. Vypište první 3 známky" ] }, { "cell_type": "code", "execution_count": 4, "id": "a46225189a698176", "metadata": { "ExecuteTime": { "end_time": "2026-02-13T10:35:32.238400541Z", "start_time": "2026-02-13T10:35:32.050466719Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "1\n", "2\n", "1\n" ] }, { "data": { "text/plain": [ "[1, 2, 1]" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "pos = 0\n", "while pos < 3:\n", " print(znamky[pos])\n", " pos += 1\n", "\n", "znamky[:3]" ] }, { "cell_type": "markdown", "id": "d4e7ef4a3addd711", "metadata": {}, "source": [ "### 3. Vypište poslední tři známky" ] }, { "cell_type": "code", "execution_count": 5, "id": "e86c5969b8b2d703", "metadata": { "ExecuteTime": { "end_time": "2026-02-13T10:47:24.859820677Z", "start_time": "2026-02-13T10:47:24.659909787Z" } }, "outputs": [ { "data": { "text/plain": [ "[2, 4, 1]" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "znamky[-3:]" ] }, { "cell_type": "markdown", "id": "40f5853d88d50a34", "metadata": {}, "source": [ "### 4. Přidejte známku 2 na konec seznamu" ] }, { "cell_type": "code", "execution_count": 6, "id": "59ec69e935fb726e", "metadata": { "ExecuteTime": { "end_time": "2026-02-13T09:11:33.489869572Z", "start_time": "2026-02-13T09:11:33.414620353Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[1, 2, 1, 3, 1, 5, 2, 4, 1, 2]\n" ] } ], "source": [ "znamky.append(2)\n", "print(znamky)" ] }, { "cell_type": "markdown", "id": "fc90c7b55bf5fe80", "metadata": {}, "source": [ "### 5. Student si test za 5 opravil na 2, proveďte tuto opravu i v seznamu" ] }, { "cell_type": "code", "execution_count": 8, "id": "af29596c2f785ddb", "metadata": { "ExecuteTime": { "end_time": "2026-02-13T11:22:25.510279256Z", "start_time": "2026-02-13T11:22:25.428068365Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[1, 2, 1, 3, 1, 2, 2, 4, 1, 2]\n" ] } ], "source": [ "znamky[5] = 2\n", "print(znamky)" ] }, { "cell_type": "markdown", "id": "40dc152802908d06", "metadata": {}, "source": [ "### 6. Vypočítejte průměr známek" ] }, { "cell_type": "code", "execution_count": 9, "id": "f6a37da90c524de5", "metadata": { "ExecuteTime": { "end_time": "2026-02-13T11:22:28.052101873Z", "start_time": "2026-02-13T11:22:27.939209924Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "19\n", "1.9\n" ] } ], "source": [ "soucet = 0\n", "for znamka in znamky:\n", " soucet += znamka\n", "\n", "print(soucet)\n", "\n", "prumer = soucet / len(znamky)\n", "print(prumer)" ] }, { "cell_type": "markdown", "id": "35dd427cdfee998f", "metadata": {}, "source": [ "### 7. (BONUS) Najděte polohu nejhorší známky" ] }, { "cell_type": "code", "execution_count": 10, "id": "4343c0cfa338f584", "metadata": { "ExecuteTime": { "end_time": "2026-02-13T11:23:54.503952914Z", "start_time": "2026-02-13T11:23:54.344567918Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "7 4\n", "[1, 2, 1, 3, 1, 2, 2, 4, 1, 2]\n" ] } ], "source": [ "poloha = -1\n", "nejhorsi_znamka = -1\n", "\n", "for pos in range(len(znamky)):\n", " znamka = znamky[pos]\n", " if znamka > nejhorsi_znamka:\n", " nejhorsi_znamka = znamka\n", " poloha = pos\n", "\n", "print(poloha, nejhorsi_znamka)\n", "print(znamky)" ] }, { "cell_type": "markdown", "id": "9e97059e4620cfb3", "metadata": {}, "source": [ "## Slovník" ] }, { "cell_type": "code", "execution_count": null, "id": "5251d41430e043c8", "metadata": {}, "outputs": [], "source": [ "car1 = {\n", " 'manufacturer': 'Skoda',\n", " 'model': 'Fabia I',\n", " 'year': 2006,\n", " 'engine': '1.2 HTP',\n", " 'power': 40,\n", " 'price_czk': 45000\n", "}" ] }, { "cell_type": "markdown", "id": "373db361792c0cbd", "metadata": {}, "source": [ "### 1. Vypište rok výroby vozidla" ] }, { "cell_type": "code", "execution_count": null, "id": "b5c26c157d1ba650", "metadata": {}, "outputs": [], "source": [ "# TODO" ] }, { "cell_type": "markdown", "id": "455c24673c70cfa1", "metadata": {}, "source": [ "### 2. Vypište výkon vozidla" ] }, { "cell_type": "code", "execution_count": null, "id": "87f3ab61d1aebc76", "metadata": {}, "outputs": [], "source": [ "# TODO" ] }, { "cell_type": "markdown", "id": "bdfb394818f0c90e", "metadata": {}, "source": [ "### 3. Po měření se zjistilo, že během let ztratila Fabia 5 kW, upravte inforamci ve slovníku" ] }, { "cell_type": "code", "execution_count": null, "id": "75afe1dcbe5565c9", "metadata": {}, "outputs": [], "source": [ "# TODO" ] }, { "cell_type": "markdown", "id": "6d519be2fb293061", "metadata": {}, "source": [ "### 4. Mnoho zákazníků se ptá, jakou barvu má vůz. Přidejte informaci že je zelený" ] }, { "cell_type": "code", "execution_count": null, "id": "8859a37636bc7352", "metadata": {}, "outputs": [], "source": [ "# TODO" ] }, { "cell_type": "markdown", "id": "be4bae558c08afa8", "metadata": {}, "source": [ "### 5. Vůz bychom rádi prodávali i na slovensku, přidejte parametr `price_eur`. Kurz použijte _1 EUR = 24.5 CZK_" ] }, { "cell_type": "code", "execution_count": null, "id": "a1d3bb3229b696ed", "metadata": {}, "outputs": [], "source": [ "# TODO" ] }, { "cell_type": "markdown", "id": "171d3b5716f44a00", "metadata": {}, "source": [ "### 6. Přijali jsme nové vozidlo. Vytvořte pro něj další kartu obsahující stejné inforamce (parametry jsou na Vás)" ] }, { "cell_type": "code", "execution_count": null, "id": "b6120a4040980dcf", "metadata": {}, "outputs": [], "source": [ "# TODO" ] }, { "cell_type": "markdown", "id": "804ba6eb816c6a7a", "metadata": {}, "source": [ "### 7. Posílat informace o jednotlivých vozech je nepraktické, udělejte seznam všech dostupných vůzů" ] }, { "cell_type": "code", "execution_count": null, "id": "5b8e9a59a1e74118", "metadata": {}, "outputs": [], "source": [ "# TODO" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "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.13.11" } }, "nbformat": 4, "nbformat_minor": 5 }