Skip to main content

A basic utility designed to prettify and visualize fractions.

Project description

hyphenfrac

Pepy Total Downlods PyPI - Version PyPI - Python Version

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


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)

Uploaded Source

Built Distribution

hyphenfrac-2.0-py3-none-any.whl (3.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page