By Bernd Klein. Last modified: 29 Jun 2022.
On this page ➤
IntroductionThis chapter covers the various built-in operators, which Python has to offer.
OperatorsThese operations (operators) can be applied to all numeric types:
Operator Description Example +, - Addition, Subtraction 10 -3 *, % Multiplication, Modulo 27 % 710 / 3 3.3333333333333335and in Python 2.x:
10 / 3 3// Truncation Division (also known as floordivision or floor division)
10 // 3 3If at least one of the operands is a float value, we get a truncated float value as the result.
10.0 // 3 3.0 >>>A note about efficiency:
In [9]: %%timeit for x in range(1, 100): y = int(100 / x) : 100000 loops, best of 3: 11.1 μs per loop In [10]: %%timeit for x in range(1, 100): y = 100 // x : 100000 loops, best of 3: 4.48 μs per loop+x, -x Unary minus and Unary plus (Algebraic signs) -3 ~x Bitwise negation ~3 - 4
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4