{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "e0ef34fa",
   "metadata": {},
   "source": [
    "# 09-09 · Jaka jest różnica między = a == oraz jak porównywać łańcuch znaków\n",
    "\n",
    "Praktyka do sekcji [„Jaka jest różnica między = a == oraz jak porównać łańcuch znaków”"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1e211050",
   "metadata": {},
   "source": [
    "## Cel\n",
    "\n",
    "Nie myl = i ==, masteruj != i porównuj łańcuch znaków."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8f9501f5",
   "metadata": {},
   "source": [
    "## Sprawa robocza"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "04afe8e2",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-16T17:23:01.825789Z",
     "iopub.status.busy": "2026-08-16T17:23:01.825679Z",
     "iopub.status.idle": "2026-08-16T17:23:01.848365Z",
     "shell.execute_reply": "2026-08-16T17:23:01.846791Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "True\n"
     ]
    }
   ],
   "source": [
    "name = \"Anna\"\n",
    "print(name == \"Anna\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a05c1bfa",
   "metadata": {},
   "source": [
    "## Typowy błąd\n",
    "\n",
    "Single `=` w tym warunku jest błąd składniowy."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "c35ab2d2",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-16T17:23:01.850384Z",
     "iopub.status.busy": "2026-08-16T17:23:01.850124Z",
     "iopub.status.idle": "2026-08-16T17:23:01.853216Z",
     "shell.execute_reply": "2026-08-16T17:23:01.852740Z"
    },
    "tags": [
     "raises-exception"
    ]
   },
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "invalid syntax. Maybe you meant '==' or ':=' instead of '='? (638216577.py, line 2)",
     "output_type": "error",
     "traceback": [
      "  \u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[2]\u001b[39m\u001b[32m, line 2\u001b[39m\n\u001b[31m    \u001b[39m\u001b[31mif age = 20:\u001b[39m\n       ^\n\u001b[31mSyntaxError\u001b[39m\u001b[31m:\u001b[39m invalid syntax. Maybe you meant '==' or ':=' instead of '='?\n"
     ]
    }
   ],
   "source": [
    "age = 20\n",
    "if age = 20:\n",
    "    print(\"Совпадает\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5ebef85a",
   "metadata": {},
   "source": [
    "## Poprawka"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "4c41c6cd",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-16T17:23:01.854601Z",
     "iopub.status.busy": "2026-08-16T17:23:01.854461Z",
     "iopub.status.idle": "2026-08-16T17:23:01.857296Z",
     "shell.execute_reply": "2026-08-16T17:23:01.856598Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Совпадает\n"
     ]
    }
   ],
   "source": [
    "age = 20\n",
    "if age == 20:\n",
    "    print(\"Совпадает\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "74eaabf5",
   "metadata": {},
   "source": [
    "## Podstawowa praktyka zadań ★\n",
    "\n",
    "Sprawdź wiek `==`, porównaj dwa słowa alfabetycznie i porównaj łańcuch znaków bez względu na wielka literę przez `.lower()`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "7e148226",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-16T17:23:01.858431Z",
     "iopub.status.busy": "2026-08-16T17:23:01.858292Z",
     "iopub.status.idle": "2026-08-16T17:23:01.862139Z",
     "shell.execute_reply": "2026-08-16T17:23:01.861573Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "True True True\n"
     ]
    }
   ],
   "source": [
    "age = 20\n",
    "is_adult = age == 20\n",
    "apple_before_banana = \"apple\" < \"banana\"\n",
    "same_case_insensitive = \"Python\".lower() == \"python\".lower()\n",
    "print(is_adult, apple_before_banana, same_case_insensitive)"
   ]
  }
 ],
 "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
}
