Advertisement
rfmonk

operator_math.py

Jan 16th, 2014
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.93 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3.  
  4. from operator import *
  5.  
  6. a = -1
  7. b = 5.0
  8. c = 2
  9. d = 6
  10.  
  11. print 'a =', a
  12. print 'b =', b
  13. print 'c =', c
  14. print 'd =', d
  15.  
  16. print '\nPositive/Negative:'
  17. print 'abs(a):', abs(a)
  18. print 'neg(a):', neg(a)
  19. print 'neg(b):', neg(b)
  20. print 'pos(a):', pos(a)
  21. print 'pos(b):', pos(b)
  22.  
  23. print '\nArithmetic:'
  24. print 'add(a, b)    :', add(a, b)
  25. print 'div(a, b)    :', div(a, b)
  26. print 'div(d, c)    :', div(d, c)
  27. print 'floordiv(a, b)    :', floordiv(a, b)
  28. print 'floordiv(d, c)    :', floordiv(d, c)
  29. print 'mod(a, b)    :', mod(a, b)
  30. print 'mul(a, b)    :', mul(a, b)
  31. print 'pow(c, d)    :', pow(c, d)
  32. print 'sub(b, a)    :', sub(b, a)
  33. print 'truediv(a, b)    :', truediv(a, b)
  34. print 'truediv(d, c)    :', truediv(d, c)
  35.  
  36. print '\nBitwise:'
  37. print 'and_(c, d)   :', and_(c, d)
  38. print 'invert(c)    :', invert(c)
  39. print 'lshift(c, d) :', lshift(c, d)
  40. print 'or_(c, d)    :', or_(c, d)
  41. print 'rshift(c, d) :', rshift(c, d)
  42. print 'xor(c, d)    :', xor(c, d)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement