Advertisement
Guest User

Untitled

a guest
Nov 24th, 2014
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. from fractions import Fraction
  2.  
  3. a, b = input('Input the numerator and denominator').split()
  4. a, b = [int(a), int(b)]
  5. c = a/b
  6. d = int(c)
  7. e = d*b
  8. f = a-e
  9. g = f/b
  10. h = Fraction(g).limit_denominator(1000)
  11. i = Fraction(c).limit_denominator(1000)
  12.  
  13. if c < 1 : (
  14. print(str(a) + '/' + str(b) + ' is equal to ' + str(i))
  15. )
  16. if h == 0: (
  17. print(str(a) + '/' + str(b) + ' is equal to ' + str(d))
  18. )
  19. else: (
  20. print(str(a) + '/' + str(b) + ' is equal to ' + str(d) + ' ' + str(h))
  21. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement