%global _empty_manifest_terminate_build 0 Name: python-Fraction Version: 2.2.0 Release: 1 Summary: Fraction carries out all the fraction operations including addition, subtraction, multiplication, division, reciprocation License: MIT License URL: https://github.com/bradley101/fraction Source0: https://mirrors.nju.edu.cn/pypi/web/packages/5f/77/4d0ad9332ebf561d6966e0c7d9daecefd2031cd0dd73f9d1760cac3ae0ec/Fraction-2.2.0.tar.gz BuildArch: noarch %description # fraction [![Downloads](https://pepy.tech/badge/fraction/week)](https://pepy.tech/project/fraction) fraction is a _Python_ module that is designed for fractional values **_numerator/denominator_** ### Installation Easy to install ``` $ python -m pip install Fraction ``` ### Usage #### Import ``` >>> from fraction import Fraction ``` #### Initialization ##### Creates a fraction equal to 0/1 ``` >>> f1 = Fraction() ``` ##### Creates a fraction equal to (1/2) / (1/4) ``` >>> print(Fraction('1/2', '1/4')) 2/1 ``` ##### Create fraction objects from strings and decimals ``` >>> print(Fraction('1.2')) 6/5 >>> print(Fraction('1.22/6')) 61/300 ``` ##### Create fraction objects from recurring decimals ``` >>> f = Fraction.fromdecimal(1.3, rec='3') >>> print(f) 4/3 >>> f = Fraction.fromdecimal(24.5067, rec='067') >>> print(f) 122411/4995 ``` ##### Creates a fraction equal to 3/10 ``` >>> a = Fraction('3/10') >>> b = Fraction('1/2') # Get numerator/denominator >>> a.numerator, a.denominator (3, 10) ``` ### Arithmetic Operations ##### Computes reciprocal of fraction as Fraction object ``` >>> recip_a = Fraction.reciprocal(a) >>> recip_a.numerator, recip_a.denominator (10, 3) ``` ##### Perform addition of Fraction objects (returns a Fraction object) ``` >>> sum_ab = a + b >>> sum_ab.numerator, sum_ab.denominator (4, 5) ``` ##### Perform subtraction of Fraction objects (returns a Fraction object) ``` >>> diff_ab = a - b >>> diff_ab.numerator, diff_ab.denominator (-1, 5) ``` ##### Perform multiplication of Fraction objects (returns a Fraction object) ``` >>> mul_ab = a * b >>> mul_ab.numerator, mul_ab.denominator (3, 20) ``` ##### Perform div of Fraction objects (returns a Fraction object) ``` >>> div_ab = a / b >>> div_ab.numerator, div_ab.denominator (3, 5) ``` ### Comparison/Relational operations ##### Supports comparison operations [<, <=, >, >=, ==, !=] (returns boolean) ``` >>> a < b True >>> a == Fraction(7, 10) False ``` ### Convert fraction into a float string ``` >>> a = Fraction('1/3') >>> a.todecimal(decplaces=5) '0.33333' ``` ### For debugging ##### Supports str() and repr() built in objects methods ``` >>> a = Fraction() >>> print a 0/1 >>> a Fraction: 0/1 ``` %package -n python3-Fraction Summary: Fraction carries out all the fraction operations including addition, subtraction, multiplication, division, reciprocation Provides: python-Fraction BuildRequires: python3-devel BuildRequires: python3-setuptools BuildRequires: python3-pip %description -n python3-Fraction # fraction [![Downloads](https://pepy.tech/badge/fraction/week)](https://pepy.tech/project/fraction) fraction is a _Python_ module that is designed for fractional values **_numerator/denominator_** ### Installation Easy to install ``` $ python -m pip install Fraction ``` ### Usage #### Import ``` >>> from fraction import Fraction ``` #### Initialization ##### Creates a fraction equal to 0/1 ``` >>> f1 = Fraction() ``` ##### Creates a fraction equal to (1/2) / (1/4) ``` >>> print(Fraction('1/2', '1/4')) 2/1 ``` ##### Create fraction objects from strings and decimals ``` >>> print(Fraction('1.2')) 6/5 >>> print(Fraction('1.22/6')) 61/300 ``` ##### Create fraction objects from recurring decimals ``` >>> f = Fraction.fromdecimal(1.3, rec='3') >>> print(f) 4/3 >>> f = Fraction.fromdecimal(24.5067, rec='067') >>> print(f) 122411/4995 ``` ##### Creates a fraction equal to 3/10 ``` >>> a = Fraction('3/10') >>> b = Fraction('1/2') # Get numerator/denominator >>> a.numerator, a.denominator (3, 10) ``` ### Arithmetic Operations ##### Computes reciprocal of fraction as Fraction object ``` >>> recip_a = Fraction.reciprocal(a) >>> recip_a.numerator, recip_a.denominator (10, 3) ``` ##### Perform addition of Fraction objects (returns a Fraction object) ``` >>> sum_ab = a + b >>> sum_ab.numerator, sum_ab.denominator (4, 5) ``` ##### Perform subtraction of Fraction objects (returns a Fraction object) ``` >>> diff_ab = a - b >>> diff_ab.numerator, diff_ab.denominator (-1, 5) ``` ##### Perform multiplication of Fraction objects (returns a Fraction object) ``` >>> mul_ab = a * b >>> mul_ab.numerator, mul_ab.denominator (3, 20) ``` ##### Perform div of Fraction objects (returns a Fraction object) ``` >>> div_ab = a / b >>> div_ab.numerator, div_ab.denominator (3, 5) ``` ### Comparison/Relational operations ##### Supports comparison operations [<, <=, >, >=, ==, !=] (returns boolean) ``` >>> a < b True >>> a == Fraction(7, 10) False ``` ### Convert fraction into a float string ``` >>> a = Fraction('1/3') >>> a.todecimal(decplaces=5) '0.33333' ``` ### For debugging ##### Supports str() and repr() built in objects methods ``` >>> a = Fraction() >>> print a 0/1 >>> a Fraction: 0/1 ``` %package help Summary: Development documents and examples for Fraction Provides: python3-Fraction-doc %description help # fraction [![Downloads](https://pepy.tech/badge/fraction/week)](https://pepy.tech/project/fraction) fraction is a _Python_ module that is designed for fractional values **_numerator/denominator_** ### Installation Easy to install ``` $ python -m pip install Fraction ``` ### Usage #### Import ``` >>> from fraction import Fraction ``` #### Initialization ##### Creates a fraction equal to 0/1 ``` >>> f1 = Fraction() ``` ##### Creates a fraction equal to (1/2) / (1/4) ``` >>> print(Fraction('1/2', '1/4')) 2/1 ``` ##### Create fraction objects from strings and decimals ``` >>> print(Fraction('1.2')) 6/5 >>> print(Fraction('1.22/6')) 61/300 ``` ##### Create fraction objects from recurring decimals ``` >>> f = Fraction.fromdecimal(1.3, rec='3') >>> print(f) 4/3 >>> f = Fraction.fromdecimal(24.5067, rec='067') >>> print(f) 122411/4995 ``` ##### Creates a fraction equal to 3/10 ``` >>> a = Fraction('3/10') >>> b = Fraction('1/2') # Get numerator/denominator >>> a.numerator, a.denominator (3, 10) ``` ### Arithmetic Operations ##### Computes reciprocal of fraction as Fraction object ``` >>> recip_a = Fraction.reciprocal(a) >>> recip_a.numerator, recip_a.denominator (10, 3) ``` ##### Perform addition of Fraction objects (returns a Fraction object) ``` >>> sum_ab = a + b >>> sum_ab.numerator, sum_ab.denominator (4, 5) ``` ##### Perform subtraction of Fraction objects (returns a Fraction object) ``` >>> diff_ab = a - b >>> diff_ab.numerator, diff_ab.denominator (-1, 5) ``` ##### Perform multiplication of Fraction objects (returns a Fraction object) ``` >>> mul_ab = a * b >>> mul_ab.numerator, mul_ab.denominator (3, 20) ``` ##### Perform div of Fraction objects (returns a Fraction object) ``` >>> div_ab = a / b >>> div_ab.numerator, div_ab.denominator (3, 5) ``` ### Comparison/Relational operations ##### Supports comparison operations [<, <=, >, >=, ==, !=] (returns boolean) ``` >>> a < b True >>> a == Fraction(7, 10) False ``` ### Convert fraction into a float string ``` >>> a = Fraction('1/3') >>> a.todecimal(decplaces=5) '0.33333' ``` ### For debugging ##### Supports str() and repr() built in objects methods ``` >>> a = Fraction() >>> print a 0/1 >>> a Fraction: 0/1 ``` %prep %autosetup -n Fraction-2.2.0 %build %py3_build %install %py3_install install -d -m755 %{buildroot}/%{_pkgdocdir} if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi pushd %{buildroot} if [ -d usr/lib ]; then find usr/lib -type f -printf "\"/%h/%f\"\n" >> filelist.lst fi if [ -d usr/lib64 ]; then find usr/lib64 -type f -printf "\"/%h/%f\"\n" >> filelist.lst fi if [ -d usr/bin ]; then find usr/bin -type f -printf "\"/%h/%f\"\n" >> filelist.lst fi if [ -d usr/sbin ]; then find usr/sbin -type f -printf "\"/%h/%f\"\n" >> filelist.lst fi touch doclist.lst if [ -d usr/share/man ]; then find usr/share/man -type f -printf "\"/%h/%f.gz\"\n" >> doclist.lst fi popd mv %{buildroot}/filelist.lst . mv %{buildroot}/doclist.lst . %files -n python3-Fraction -f filelist.lst %dir %{python3_sitelib}/* %files help -f doclist.lst %{_docdir}/* %changelog * Thu Jun 08 2023 Python_Bot - 2.2.0-1 - Package Spec generated