Skip to main content

Add all types of functions with fractions

Project description

RealFractions

Python library who adds functions related to the operation and conversion of fractions in a string format, with specific classes depending on what needs to be done.

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

Make sure you have Python and that the expected version is available from your command line. You can check this by running:

python --version

You should get some output like Python 3.6.3. If you do not have Python, please install the latest 3.x version from python.org

Additionally, you’ll need to make sure you have pip available. You can check this by running:

pip --version

If you installed Python from source, with an installer from python.org you should already have pip. If you’re on Linux and installed using your OS package manager, you may have to install pip separately, see Installing pip/setuptools/wheel with Linux Package Managers.

If pip isn’t already installed, then first try to bootstrap it from the standard library:

python -m ensurepip --default-pip

While pip alone is sufficient to install from pre-built binary archives, up to date copies of the setuptools and wheel projects are useful to ensure you can also install from source archives:

python -m pip install --upgrade pip setuptools wheel

Installing

To install the latest version of RealFractions:

pip install -U real-fractions

And then you can import this library in Python:

from real_fractions import convert

fraction = "1/2"
fraction = to_decimal(fraction)

print(string)
# Output: 0.5

Or you can check the project in PyPI.

Running the tests

To run automated module tests you first need to install py.test:

pip install -U py.test

Then you must to download the source code of the module in his github repository, go to the tests folder with PowerShell and run pytest:

pytest

Some test examples

These are some examples of the automated test

    def test_simplify(self):
        """Test simplify method from Fractions."""

        # Normal cases
        assert self.simplify("5/10") == "1/2"
        assert self.simplify("-12/4") == "-3/1"
        assert self.simplify("10/-2") == "-5/1"
        assert self.simplify("-20/-2") == "10/1"

        # Invalid arguments
        assert self.simplify("10/0") is None
        assert self.simplify(True) is None
        assert self.simplify("Error") is None

This test is testing all the general cases of the function simplify of the core module.

Built With

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

  • Lucas Mosquera - Creator and maintainer - PurpleBooth

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Acknowledgments

This is my second package that I publish as open source, it was a project that I proposed as a challenge to practice programming, I am still a junior programmer but I tried to do my best. Thanks anyway for getting here, a kiss.

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

real-fractions-1.1.1.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

real_fractions-1.1.1-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file real-fractions-1.1.1.tar.gz.

File metadata

  • Download URL: real-fractions-1.1.1.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.5

File hashes

Hashes for real-fractions-1.1.1.tar.gz
Algorithm Hash digest
SHA256 a4416b187a58bd386d6906f5ccdb890b3bb76ad5e7892ef42393af50bba121e1
MD5 a8faa6f1a85cd1fa74d8fdf778a4944c
BLAKE2b-256 e1f493bef6de7d87a9c4c8652866736c21eed9bb45bc0da4c15789b791aeec71

See more details on using hashes here.

File details

Details for the file real_fractions-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: real_fractions-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 9.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.5

File hashes

Hashes for real_fractions-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 60eac57153050878e8619564e35b073a5ede9ba24b06162449f357c094039301
MD5 4f5b294b92f97ec7dd471f4f65089b2f
BLAKE2b-256 334b8d054fe50a071e3452309b968176880dde6e4481220438d2c1a1bf472525

See more details on using hashes here.

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