Frasty is a python library that allows you to easily calculate fractions
Project description
Frasty
Frasty is a python library that allows you to easily calculate fractions
📦 Installation
You can install Frasty via pip :
pip install frasty
🚀 Use
from Frasty.Fraction import Fraction
# Creating fractions
f1 = Fraction(3, 5)
f2 = Fraction(4, 3)
f3 = Fraction(-2, 7)
f4 = Fraction(6, 8) # will be simplified to 3/4
print("Fractions cree :")
print(f"f1 = {f1}")
print(f"f2 = {f2}")
print(f"f3 = {f3}")
print(f"f4 = {f4} (simplifier)")
print("\nRepresentation officielle (repr) :")
print(repr(f1))
print(repr(f4))
# Arithmetic operations
print("\nOperations arithmetiques :")
print(f"f1 + f2 = {f1 + f2}")
print(f"f1 - f2 = {f1 - f2}")
print(f"f1 * f2 = {f1 * f2}")
print(f"f1 / f2 = {f1 / f2}")
# Operations with integers
print("\nAvec des entiers :")
print(f"f1 + 2 = {f1 + 2}")
print(f"2 + f1 = {2 + f1}")
print(f"f1 * 3 = {f1 * 3}")
print(f"3 * f1 = {3 * f1}")
print(f"f1 - 1 = {f1 - 1}")
print(f"1 - f1 = {1 - f1}")
print(f"f1 / 2 = {f1 / 2}")
print(f"2 / f1 = {2 / f1}")
# Comparisons
print("\nComparaisons :")
print(f"f1 == Fraction(3,5) ? {f1 == Fraction(3,5)}") # True
print(f"f1 == f2 ? {f1 == f2}") # False
print(f"f1 != f2 ? {f1 != f2}") # True
print(f"f1 < f2 ? {f1 < f2}") # True
print(f"f1 <= Fraction(3,5) ? {f1 <= Fraction(3,5)}") # True
print(f"f1 > f3 ? {f1 > f3}") # True
print(f"f1 >= Fraction(1,2) ? {f1 >= Fraction(1,2)}") # True
# Comparisons with integers
print("\nComparaisons avec entiers :")
print(f"f1 == 6 ? {f1 == 6}")
print(f"f1 < 1 ? {f1 < 1}")
print(f"f1 <= 2 ? {f1 <= 2}")
print(f"f1 > 0 ? {f1 > 0}")
print(f"f1 >= 2 ? {f1 >= 2}")
# Checking addition and equality
print("\nTest egalite apres addition :")
if f1 + f2 == Fraction(29, 15):
print(f"{f1} + {f2} = 29/15 (correct)")
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
frasty-1.0.0.tar.gz
(4.5 kB
view details)
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 frasty-1.0.0.tar.gz.
File metadata
- Download URL: frasty-1.0.0.tar.gz
- Upload date:
- Size: 4.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6e760bf170a375644589f98c131ca36897192c06fb9588f89cb63b17d91f46a0
|
|
| MD5 |
e11a68ff350707b4fb388d8c8a2847db
|
|
| BLAKE2b-256 |
0d9bbe41b31cf945df3654d4b1723b51c3eb4b52dd1c1edfa47aa44f2e203926
|
File details
Details for the file frasty-1.0.0-py3-none-any.whl.
File metadata
- Download URL: frasty-1.0.0-py3-none-any.whl
- Upload date:
- Size: 3.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1f8d7eb64a81106d6e27312d004bcac2fa212362f57be7c0a3b7d46b6d59c837
|
|
| MD5 |
82efbde5d14e8d1166f6647787d412b9
|
|
| BLAKE2b-256 |
99ee856f596e7155e34002c6e5204fa3c96cf35e469b900c6f44f3e973e5b634
|