{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "e717eaaf",
   "metadata": {},
   "source": [
    "# 04-17 · Fraction и точные дроби\n",
    "\n",
    "Практика к разделу [«Fraction — точные дроби»](../../site/chapters/glava-04/04-17-fraction.html)."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "74bdc79c",
   "metadata": {},
   "source": [
    "## Цель\n",
    "\n",
    "Освоить точную рациональную арифметику."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6afb1945",
   "metadata": {},
   "source": [
    "## Рабочий пример"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "3a2670da",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-16T10:03:45.928337Z",
     "iopub.status.busy": "2026-08-16T10:03:45.928161Z",
     "iopub.status.idle": "2026-08-16T10:03:45.949618Z",
     "shell.execute_reply": "2026-08-16T10:03:45.949120Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1/3\n"
     ]
    }
   ],
   "source": [
    "from fractions import Fraction\n",
    "print(Fraction(1, 3))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7dbc22e7",
   "metadata": {},
   "source": [
    "## Эксперимент 1\n",
    "\n",
    "Сложите две дроби точно."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "4d4884f3",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-16T10:03:45.950649Z",
     "iopub.status.busy": "2026-08-16T10:03:45.950524Z",
     "iopub.status.idle": "2026-08-16T10:03:45.952824Z",
     "shell.execute_reply": "2026-08-16T10:03:45.952358Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1/2\n"
     ]
    }
   ],
   "source": [
    "from fractions import Fraction\n",
    "print(Fraction(1, 3) + Fraction(1, 6))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "10a31e1b",
   "metadata": {},
   "source": [
    "## Задание ★ Базовая практика\n",
    "\n",
    "Создайте Fraction(\"0.1\") из текста и Fraction(0.1) из float — сравните их."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "5bc5534c",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-16T10:03:45.953832Z",
     "iopub.status.busy": "2026-08-16T10:03:45.953645Z",
     "iopub.status.idle": "2026-08-16T10:03:45.955995Z",
     "shell.execute_reply": "2026-08-16T10:03:45.955572Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1/10\n",
      "3602879701896397/36028797018963968\n"
     ]
    }
   ],
   "source": [
    "from fractions import Fraction\n",
    "print(Fraction(\"0.1\"))\n",
    "print(Fraction(0.1))"
   ]
  }
 ],
 "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
}
