Numerics¶
Comparisons¶
The following expressions can be used to compare numerical values (source: python3)
Python expression |
Meaning |
---|---|
|
not a |
|
a equal b |
|
a not equal b |
|
a and b |
|
a or b |
|
a greater equal b |
|
a greater b |
|
a less equal b |
|
a less b |
Operations¶
Binary operations are listed below (source: python3)
Python expression |
Meaning |
---|---|
|
sum of x and y |
|
difference of x and y |
|
product of x and y |
|
quotient of x and y |
|
floored quotient of x and y |
|
remainder of x / y |
|
x negated |
|
absolute value or magnitude of x |
|
a complex $re + i\times im$ |
|
conjugate of the complex number c |
|
the pair |
|
x to the power y |
|
x to the power y |
x = 13
y = 5
print(x / y) # division
print(x // y) # floored quotient
print(x % y) # rest
print(divmod(x, y))
2.6
2
3
(2, 3)
print(pow(x, y))
print(x**y)
371293
371293
c = complex(x, y)
print(c)
print(c.real)
print(c.imag)
cc = c.conjugate()
print(cc)
print(c * cc)
print(abs(c))
(13+5j)
13.0
5.0
(13-5j)
(194+0j)
13.92838827718412
x = 11
print(x)
# x = x + 1
x += 1
print(x)
x *= 2
# x = x * 2
print(x)
# x = x / 3
x /= 3
print(x)
# x = x - 2
x -= 2
print(x)
11
12
24
8.0
6.0