A Python library for working with fractions
Project description
Fraction Calculator
The Fraction Calculator is a versatile Python library designed for performing various operations in numerator/denominator format. It enables users to work with fractions seamlessly and includes features like basic arithmetic operations, comparison methods, and more.
Features
-
Basic Arithmetic Operations:
- Addition
- Subtraction
- Multiplication
- Division
- Floor Division
- Modulus
-
Comparison Methods:
- Compare fractions using the following methods:
- Less than (
<) - Less than or equal to (
<=) - Equal to (
==) - Not equal to (
!=) - Greater than (
>) - Greater than or equal to (
>=)
- Less than (
- Compare fractions using the following methods:
Usage
To utilize the Fraction Calculator, create instances of the Fraction class and perform operations. Here's an example showcasing basic usage:
from pyfractions import Fraction
# Create Fraction objects
fraction1 = Fraction(1, 2)
fraction2 = Fraction(3, 4)
# Perform operations
sum_result = fraction1 + fraction2
difference_result = fraction1 - fraction2
product_result = fraction1 * fraction2
quotient_result = fraction1 / fraction2
# Display results
print(f'Sum: {sum_result}') # Sum: 5/4
print(f'Difference: {difference_result}') # Difference: -1/4
print(f'Product: {product_result}') # Product: 3/8
print(f'Quotient: {quotient_result}') # Quotient: 2/3
# Check if fraction1 is greater than fraction2
is_greater = fraction1 > fraction2
# Display result
print(f'Is fraction1 greater than fraction2? {is_greater}')
# Is fraction1 greater than fraction2? False
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyfractions-0.1.0.tar.gz.
File metadata
- Download URL: pyfractions-0.1.0.tar.gz
- Upload date:
- Size: 4.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0cf9deaadad46920ca8788e74c886fb226b5a6e12f6edaef9a33e58fc063161f
|
|
| MD5 |
0ef540fae79b45ffaf2d319028d23ba2
|
|
| BLAKE2b-256 |
d9822608da8abef49517b1a8214f37b0b43a8d0bb92a6270b795152e622e8bf7
|
File details
Details for the file pyfractions-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pyfractions-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e5d07acf25ca0f60726292b3ae24f040d426a3c24312c8b83e17b746ce9de4e6
|
|
| MD5 |
1a9e92824ca9fa3cdfbe78412cd7d9ac
|
|
| BLAKE2b-256 |
a65c042798c655b24035395d3e16334b308351f57a6ddacd1694545e081a26a9
|