Skip to content

Instantly share code, notes, and snippets.

@Fhernd
Created May 29, 2018 13:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Fhernd/eec75ae934085192fc67b29c0562381d to your computer and use it in GitHub Desktop.
Save Fhernd/eec75ae934085192fc67b29c0562381d to your computer and use it in GitHub Desktop.
Cálculo de fracciones en Python. OrtizOL.
from fractions import Fraction
fraccion1 = Fraction(2, 3)
fraccion2 = Fraction(5, 7)
print(fraccion1 + fraccion2)
print(fraccion1 * fraccion2)
print(fraccion1.numerator)
print(fraccion1.denominator)
print(float(fraccion2))
numero = 0.5
print(Fraction(*numero.as_integer_ratio()))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment