Advertisement
rfmonk

fractions_arithmatic.py

Jan 23rd, 2014
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.26 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3.  
  4. import fractions
  5.  
  6. f1 = fractions.Fraction(1, 2)
  7. f2 = fractions.Fraction(3, 4)
  8.  
  9. print '%s + %s = %s' % (f1, f2, f1 + f2)
  10. print '%s - %s = %s' % (f1, f2, f1 - f2)
  11. print '%s * %s = %s' % (f1, f2, f1 * f2)
  12. print '%s / %s = %s' % (f1, f2, f1 / f2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement