Skip to main content

A comprehensive codebase to calculate percentages.

Project description

Percent: A Python Package for Percentage Calculation

Inspired by the brilliant and complex project is-thirteen, I embarked on the arduous journey of creating this project. Without that monumental inspiration, I likely would have chosen an easier path in life.

Description

The percent package is designed to calculate the percentage of a given part based on a whole. With rigorous validation mechanisms and exception handling, this package ensures accurate calculations while raising meaningful errors for invalid input. Given its complexity, this project is ongoing, and your contributions are not just welcomed; they're critically needed.

Installation

You can install the package using pip:

pip install ez-percent

Usage

Here's how to make the most out of the percent package:

1. Basic Calculation

Calculate the percentage of a part relative to a whole with ease:

from percent import percent

result = percent(25, 100)
print(result)  # Output: 25.0

2. Handling Zero Division

Attempt to calculate a percentage with a whole of zero, which will trigger an appropriate error:

try:
    percent(7, 0)
except ValueError as e:
    print(e)  # Output: Whole cannot be zero. Division by zero is undefined.

3. Type Validation

Input validation ensures only valid numeric types are processed. Here's how it will respond to invalid inputs:

try:
    percent("25", 100)
except TypeError as e:
    print(e)  # Output: Both 'part' and 'whole' must be numbers (int or float).

Contributions Needed

This project is incredibly challenging and requires additional contributors who are brave enough (or foolish enough) to help unearth the complexities involved. If you have what it takes to tackle the mathematical intricacies of percentage calculations, we’d love your support!

Please fork the repository and submit pull requests for any enhancements or bug fixes.

License

This project is licensed under the Mozilla Public License Version 2.0.

While I am genuinely grateful to all the contributors who have aided in this endeavor, I cannot overlook the significant hardships I endured to publish the first version of this package. Therefore, I am disallowing unauthorized redistribution and imposing additional limitations on the use of this project.

See the LICENSE for more details.


Future Enhancements

While the current implementation serves its purpose, there are numerous avenues for improvement that can make this package even more robust and user-friendly. Some ideas include:

  • Support for Percent Ranges: Allow users to calculate percentages for a range of values, making bulk processing easier.
  • Enhanced Error Handling: Provide more detailed error messages for various numeric types and edge cases.
  • Unit Tests: Develop comprehensive unit tests to ensure the reliability of calculations.
  • Documentation: Expand documentation with more examples and detailed explanations to aid users of all skill levels.

Acknowledgments

Shout out to all who have embarked on this journey with me! Collectively, we can navigate the tricky waters of percentage calculations and tackle the complexities that lie ahead.

Contact

For any inquiries or suggestions, feel free to reach out. Collaboration is key, and I'm always open to feedback!

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

ez_percent-0.0.2.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ez_percent-0.0.2-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

Details for the file ez_percent-0.0.2.tar.gz.

File metadata

  • Download URL: ez_percent-0.0.2.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for ez_percent-0.0.2.tar.gz
Algorithm Hash digest
SHA256 b63228beb3bf35f7bb8789f666d18ec043982eafb003308f6b5d686a7b0d82e9
MD5 95cb82919e0c8f130c24de903d246e25
BLAKE2b-256 7c27419db48014fb3c598f00d30e6485f03642176b7930fc34596ff41a22ce43

See more details on using hashes here.

File details

Details for the file ez_percent-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: ez_percent-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 9.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for ez_percent-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 680a854442e2f9682bbf9a200c99105278ebf79024ee85945869b4e027c86097
MD5 082491f8e63d59e28ec44e40d2865dda
BLAKE2b-256 f61704f42b4a382de22694845324180b08e1c17cde8a3ddb7792e06f6c2747a6

See more details on using hashes here.

Supported by

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