|
| 1 | +import operator |
| 2 | + |
| 3 | + |
| 4 | +a = -1 |
| 5 | +b = 5.0 |
| 6 | +c = 2 |
| 7 | +d = 6 |
| 8 | + |
| 9 | + |
| 10 | +print('a =', a) |
| 11 | +print('b =', b) |
| 12 | +print('c =', c) |
| 13 | +print('d =', d) |
| 14 | + |
| 15 | +print('\nPositive/Negative:') |
| 16 | +print('abs(a): ', operator.abs(a)) |
| 17 | +print('neg(a): ', operator.neg(a)) |
| 18 | +print('neg(b): ', operator.neg(b)) |
| 19 | +print('pos(a): ', operator.pos(a)) |
| 20 | +print('pos(b): ', operator.pos(b)) |
| 21 | + |
| 22 | +print('\nArithmetic:') |
| 23 | +print('add(a, b): ', operator.add(a, b)) |
| 24 | +print('floordiv(a, b): ', operator.floordiv(a, b)) |
| 25 | +print('floordiv(d, c): ', operator.floordiv(d, c)) |
| 26 | +print('mod(a, b): ', operator.mod(a, b)) |
| 27 | +print('mul(a, b): ', operator.mul(a, b)) |
| 28 | +print('pow(c, d): ', operator.pow(c, d)) |
| 29 | +print('sub(b, a): ', operator.sub(b, a)) |
| 30 | +print('truediv(a, b): ', operator.truediv(a, b)) |
| 31 | +print('truediv(d, c): ', operator.truediv(d, c)) |
| 32 | + |
| 33 | +print('\nBitwise:') |
| 34 | +print('and_(c, d): ', operator.and_(c, d)) |
| 35 | +print('invert(c): ', operator.invert(c)) |
| 36 | +print('lshift(c, d): ', operator.lshift(c, d)) |
| 37 | +print('or_(c, d): ', operator.or_(c, d)) |
| 38 | +print('rshift(d, c): ', operator.rshift(d, c)) |
| 39 | +print('xor(c, d): ', operator.xor(c, d)) |
| 40 | + |
0 commit comments