{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "db7ae7ef",
   "metadata": {},
   "source": [
    "# 04-14 · Napraw porównanie float\n",
    "\n",
    "Praktyka do sekcji [„Porównujemy float poprawnie”](/pl/chapters/rozdzial-04/04-14-sravnenie-float.html)."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a81fd057",
   "metadata": {},
   "source": [
    "## Cel\n",
    "\n",
    "Zastąp niezawodne == przez math.isclose()."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c01419da",
   "metadata": {},
   "source": [
    "## Sprawa robocza\n",
    "\n",
    "To porównanie jest zawodliwe — sprawdź sam."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "acec8c4b",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-16T10:03:40.089802Z",
     "iopub.status.busy": "2026-08-16T10:03:40.089651Z",
     "iopub.status.idle": "2026-08-16T10:03:40.105854Z",
     "shell.execute_reply": "2026-08-16T10:03:40.105304Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "False\n"
     ]
    }
   ],
   "source": [
    "print(0.1 + 0.2 == 0.3)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b2c34870",
   "metadata": {},
   "source": [
    "## Poprawka"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "3c4ea781",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-16T10:03:40.106794Z",
     "iopub.status.busy": "2026-08-16T10:03:40.106692Z",
     "iopub.status.idle": "2026-08-16T10:03:40.109536Z",
     "shell.execute_reply": "2026-08-16T10:03:40.108749Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "True\n"
     ]
    }
   ],
   "source": [
    "from math import isclose\n",
    "print(isclose(0.1 + 0.2, 0.3))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f1b92662",
   "metadata": {},
   "source": [
    "## Podstawowa praktyka zadań ★\n",
    "\n",
    "Popraw porównanie `1.1 + 2.2 == 3.3`używanie isclose()."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "426f656a",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-16T10:03:40.110789Z",
     "iopub.status.busy": "2026-08-16T10:03:40.110621Z",
     "iopub.status.idle": "2026-08-16T10:03:40.113266Z",
     "shell.execute_reply": "2026-08-16T10:03:40.112747Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "True\n"
     ]
    }
   ],
   "source": [
    "from math import isclose\n",
    "print(isclose(1.1 + 2.2, 3.3))"
   ]
  }
 ],
 "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
}
