Skip to main content

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)")

# This method returns the value of a fraction in decimal
print(Fraction(14, 6).display_the_value_in_decimal()) # 2.3333333333333335
print(Fraction(13, 8).display_the_value_in_decimal()) # 1.625

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

frasty-1.1.0.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

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

frasty-1.1.0-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file frasty-1.1.0.tar.gz.

File metadata

  • Download URL: frasty-1.1.0.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.0

File hashes

Hashes for frasty-1.1.0.tar.gz
Algorithm Hash digest
SHA256 6222edf8aeefe649c55ac236a4ffd885b1762808d8b72023cbfefedee55ddea3
MD5 c148b44e3a295a0aca4814705687d980
BLAKE2b-256 cf42926df71cb2d06e569cfdb0d96adca17d73f2cad1469ec9aca19c7c79342d

See more details on using hashes here.

File details

Details for the file frasty-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: frasty-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.0

File hashes

Hashes for frasty-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 210187f9d3a975582f8d731eff7af6981773f35800b0eeab86b862b782b76adc
MD5 d9e996e1508d8ce703b79a5d81a92fb5
BLAKE2b-256 d9f69120701b50ad46491046e38f84879edcfbde9a2fdfe3843b2e2bab9357e8

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