{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Funksiyalar va kolleksiyalar — 3-dars\n",
    "## Amaliy topshiriqlar\n",
    "\n",
    "**Mavzular:** tuple, set, dict, `def`, `return`, standart parametrlar, `*args` / `**kwargs`, koʻrinish sohasi, `lambda`\n",
    "\n",
    "`pass` oʻrniga oʻz kodingizni yozing va katakni ishga tushiring (Shift + Enter)."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "---\n",
    "## 1-topshiriq. Toʻrtburchak yuzasi\n",
    "\n",
    "`area(width, height)` funksiyasini yozing. `area(5, 3)` da tekshiring."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Sizning kodingiz\n",
    "pass"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "---\n",
    "## 2-topshiriq. Min, Max, Avg funksiya orqali\n",
    "\n",
    "`summary(numbers)` funksiyasini yozing — roʻyxatdan `(min, max, avg)` tuple qaytarsin. Natijani uchta oʻzgaruvchiga ajrating.\n",
    "\n",
    "```python\n",
    "data = [12, 7, 23, 9, 31, 4, 18]\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "data = [12, 7, 23, 9, 31, 4, 18]\n",
    "\n",
    "# Sizning kodingiz\n",
    "pass"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "---\n",
    "## 3-topshiriq. Noyob soʻzlar\n",
    "\n",
    "Berilgan satrdagi noyob soʻzlar sonini `set` orqali aniqlang (registr ahamiyatsiz).\n",
    "\n",
    "```python\n",
    "text = \"Python is great Python is fun and Python is fast\"\n",
    "```\n",
    "\n",
    "Kutilgan natija: 7."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "text = \"Python is great Python is fun and Python is fast\"\n",
    "\n",
    "# Sizning kodingiz\n",
    "pass"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "---\n",
    "## 4-topshiriq. Harflar chastotasi\n",
    "\n",
    "Berilgan soʻz uchun `{harf: soni}` lugʻat tuzing (boʻshliqlarsiz, registr ahamiyatsiz).\n",
    "\n",
    "```python\n",
    "word = \"programming\"\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "word = \"programming\"\n",
    "\n",
    "# Sizning kodingiz\n",
    "pass"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "---\n",
    "## 5-topshiriq. Lugʻatlarni birlashtirish\n",
    "\n",
    "`merge(d1, d2)` funksiyasini yozing — ikkala lugʻatda bor kalit boʻlsa, `d2` qiymati ustun keladi. `|` operatoridan foydalanmang.\n",
    "\n",
    "```python\n",
    "a = {\"x\": 1, \"y\": 2}\n",
    "b = {\"y\": 99, \"z\": 3}\n",
    "# merge(a, b) → {\"x\": 1, \"y\": 99, \"z\": 3}\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Sizning kodingiz\n",
    "pass"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "---\n",
    "## 6-topshiriq. Standart parametr\n",
    "\n",
    "`power(base, exp=2)` funksiyasini yozing — `base ** exp` qaytarsin. `power(5)` va `power(2, 10)` ni tekshiring."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Sizning kodingiz\n",
    "pass"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "---\n",
    "## 7-topshiriq. *args — koʻpaytma\n",
    "\n",
    "`product(*nums)` funksiyasini yozing — barcha argumentlar koʻpaytmasini qaytarsin. Argumentsiz holatda — 1.\n",
    "\n",
    "```python\n",
    "product(2, 3, 4)   # → 24\n",
    "product()          # → 1\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Sizning kodingiz\n",
    "pass"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "---\n",
    "## 8-topshiriq. **kwargs — URL quruvchi\n",
    "\n",
    "`build_url(base, **params)` funksiyasini yozing — `base?key1=val1&key2=val2` koʻrinishidagi satrni qaytarsin.\n",
    "\n",
    "```python\n",
    "build_url(\"https://api.example.com\", lang=\"uz\", page=2)\n",
    "# → \"https://api.example.com?lang=uz&page=2\"\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Sizning kodingiz\n",
    "pass"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "---\n",
    "## 9-topshiriq. lambda orqali tartiblash\n",
    "\n",
    "Tovarlar lugʻatlari roʻyxati. Narx boʻyicha kamayish tartibida `sorted` va `lambda` bilan tartiblang.\n",
    "\n",
    "```python\n",
    "products = [\n",
    "    {\"name\": \"book\", \"price\": 12},\n",
    "    {\"name\": \"phone\", \"price\": 599},\n",
    "    {\"name\": \"pen\", \"price\": 3},\n",
    "    {\"name\": \"laptop\", \"price\": 1200},\n",
    "]\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "products = [\n",
    "    {\"name\": \"book\", \"price\": 12},\n",
    "    {\"name\": \"phone\", \"price\": 599},\n",
    "    {\"name\": \"pen\", \"price\": 3},\n",
    "    {\"name\": \"laptop\", \"price\": 1200},\n",
    "]\n",
    "\n",
    "# Sizning kodingiz\n",
    "pass"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "---\n",
    "## 10-topshiriq. Soʻzlarni uzunligi boʻyicha guruhlash\n",
    "\n",
    "`group_by_len(words)` funksiyasini yozing — `{uzunlik: [shu uzunlikdagi soʻzlar]}` lugʻatini qaytarsin.\n",
    "\n",
    "```python\n",
    "words = [\"sun\", \"moon\", \"sky\", \"star\", \"cloud\", \"rain\", \"snow\"]\n",
    "# → {3: [\"sun\", \"sky\"], 4: [\"moon\", \"star\", \"rain\", \"snow\"], 5: [\"cloud\"]}\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "words = [\"sun\", \"moon\", \"sky\", \"star\", \"cloud\", \"rain\", \"snow\"]\n",
    "\n",
    "# Sizning kodingiz\n",
    "pass"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "name": "python",
   "version": "3.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
