{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "96dffc61",
   "metadata": {},
   "source": [
    "# 13-27 · Narzędzia dla kolekcji\n",
    "\n",
    "Praktyka do sekcji [„Mini-projekty — konwerter i narzędzia kolekcji”](/pl/chapters/rozdzial-13/13-26-mini-proekt-konverter-i-utility.html#utility)."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "64b6feaa",
   "metadata": {},
   "source": [
    "## Cel\n",
    "\n",
    "Małe, skoncentrowane funkcje na górze list, zbiorów i słowników."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f7aaa1d1",
   "metadata": {},
   "source": [
    "## Podstawowa praktyka zadań ★"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "1127a5f1",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-17T18:54:24.674846Z",
     "iopub.status.busy": "2026-08-17T18:54:24.674670Z",
     "iopub.status.idle": "2026-08-17T18:54:24.697201Z",
     "shell.execute_reply": "2026-08-17T18:54:24.696741Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "80.0 2 {'python', 'code'} {'name': 'Anna', 'score': 95}\n"
     ]
    }
   ],
   "source": [
    "def average(scores):\n",
    "    return sum(scores) / len(scores)\n",
    "\n",
    "def count_above(scores, threshold):\n",
    "    return len([s for s in scores if s > threshold])\n",
    "\n",
    "def unique_words(text):\n",
    "    return set(text.lower().split())\n",
    "\n",
    "def find_top_score(students):\n",
    "    return max(students, key=lambda s: s[\"score\"])\n",
    "\n",
    "avg = average([70, 80, 90])\n",
    "above = count_above([70, 80, 90], 75)\n",
    "uniq = unique_words(\"Python python code\")\n",
    "top = find_top_score([{\"name\": \"Anna\", \"score\": 95}, {\"name\": \"Bob\", \"score\": 82}])\n",
    "\n",
    "print(avg, above, uniq, top)"
   ]
  }
 ],
 "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
}
