{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "44079977",
   "metadata": {},
   "source": [
    "# 08-16 · Metody łańcuchów: wyszukiwanie i analizowanie\n",
    "\n",
    "Praktyka do sekcji [„Metody łańcuchów znaków: wyszukiwanie i analiza”](/pl/chapters/rozdzial-08/08-16-metody-strok-poisk-i-razbor.html)."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6ddb98b5",
   "metadata": {},
   "source": [
    "## Cel\n",
    "\n",
    "Mistrz replace, split, join, count, find, index, startswith, endswith."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "93fdea64",
   "metadata": {},
   "source": [
    "## Sprawa robocza"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "54c44e05",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-16T16:18:56.091742Z",
     "iopub.status.busy": "2026-08-16T16:18:56.091630Z",
     "iopub.status.idle": "2026-08-16T16:18:56.117627Z",
     "shell.execute_reply": "2026-08-16T16:18:56.117140Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "я люблю Python\n",
      "['кот', 'и', 'пёс']\n",
      "кот-и-пёс\n"
     ]
    }
   ],
   "source": [
    "text = \"я люблю Java\"\n",
    "print(text.replace(\"Java\", \"Python\"))\n",
    "\n",
    "sentence = \"кот и пёс\"\n",
    "words = sentence.split()\n",
    "print(words)\n",
    "print(\"-\".join(words))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e57449e6",
   "metadata": {},
   "source": [
    "## Eksperyment 1 – find() i index()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "d624cda6",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-16T16:18:56.118586Z",
     "iopub.status.busy": "2026-08-16T16:18:56.118476Z",
     "iopub.status.idle": "2026-08-16T16:18:56.120690Z",
     "shell.execute_reply": "2026-08-16T16:18:56.120379Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2\n",
      "-1\n"
     ]
    }
   ],
   "source": [
    "text = \"Python\"\n",
    "print(text.find(\"th\"))\n",
    "print(text.find(\"zz\"))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9e40e410",
   "metadata": {},
   "source": [
    "## Podstawowa praktyka zadań ★\n",
    "\n",
    "Dla nazwy pliku \"report_final.pdf\" sprawdź, czy kończy się na \". pdf» (`is_pdf`), znajdź pozycję symbolu „_”`position`), i podziel nazwę według „_” na lista części (`parts`)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "f3acce30",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-16T16:18:56.121792Z",
     "iopub.status.busy": "2026-08-16T16:18:56.121678Z",
     "iopub.status.idle": "2026-08-16T16:18:56.124254Z",
     "shell.execute_reply": "2026-08-16T16:18:56.123716Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "True 6 ['report', 'final.pdf']\n"
     ]
    }
   ],
   "source": [
    "filename = \"report_final.pdf\"\n",
    "is_pdf = filename.endswith(\".pdf\")\n",
    "position = filename.find(\"_\")\n",
    "parts = filename.split(\"_\")\n",
    "print(is_pdf, position, parts)"
   ]
  }
 ],
 "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
}
