Advertisement
Guest User

Untitled

a guest
Nov 24th, 2014
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 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 = int(d)
  12.  
  13. if c < 1 : (
  14. print(str(a) + '/' + str(b) + ' is equal to ' + str(a) + '/' + str(b))
  15. )
  16.  
  17.  
  18. else: (
  19. print(str(a) + '/' + str(b) + ' is equal to ' + str(i) + ' ' + str(h))
  20. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement