A basic utility designed to prettify and visualize fractions.
Project description
hyphenfrac
A basic utility designed to prettify and visualize fractions.
Usage
Prerequisites
- A terminal accepting ANSI codes
Displaying Fractions
Displaying a prettified fraction from a number:
>>> import hyphenfrac, random
>>> hyphenfrac.visualize_number(random.randint(1, 100)/random.randint(1, 100))
20
-- + 1
49
>>>
You may also assign this value to a variable:
>>> import hyphenfrac
>>> foo = hyphenfrac.make_pretty(1, 10)
>>> print(foo)
1
--
10
>>>
You can optionally use a dash instead of a hyphen-minus character for a vinculum:
>>> import hyphenfrac
>>> hyphenfrac.visualize("ln(x) - ln(y)", "x - y", hyphen=False)
ln(x) - ln(y)
―――――――――――――
x - y
>>>
Creating Fractions
Fractions could also be used as their own object:
>>> from hyphenfrac import Fraction
>>> myFrac = Fraction(numerator="Vd", denominator="CL", operation="", whole="ln(2)", hyphen=False)
>>> myFrac.display()
Vd
―― ln(2)
CL
>>> isinstance(myFrac, Fraction)
True
>>>
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
hyphenfrac-2.0.tar.gz
(3.4 kB
view hashes)