% percentage sign for integer remainder
** Double star for exponentiation
Attenzione: "^" e' Bitwise XOR, non
esponenziazione come in Basic
/ divisione con virgola, cioe' quoziente
// floor division, il risultato ha tipo intero
+= | y += 10 | y = y + 10 | |
---|---|---|---|
-= | y -= 10 | y = y - 10 | |
*= | y *= 10 | y = y * 10 | |
/= | y /= 10 | y = y / 10 | |
%= | y %= 10 | y = y % 10 | replace the value with the old value modulo 10 |
For mutable objects like lists, arrays, or DataFrames, these augmented assignment operations are actually subtly different than their more verbose counterparts: they modify the contents of the original object rather than creating a new object to store the result.
=
single is assignment,
==
double is comparison
a == b | a != b | a uguale b, non uguale |
a < b | a > b | a minore b, maggiore |
a <= b | a >= b | a minore o uguale, maggiore o uguale |
1 < 3 < 5 unlike most programming languages, Python allows inequalities to be chained together, just as in mathematics.
a XOR b equi a != b
check for object identity.
Object identity is different than equality !
a = [1, 2, 3]
b = [1, 2, 3]
c = b
a == b
True
a is b
False
c is b
True
check for membership within compound objects.
2 in [1, 2, 3]
True
2 not in [1, 2, 3]
False
Python easy to use, es membership operators
carleton.ca/paulogarcia/how-to-confront-programming-languages
The expression x if C else y
first evaluates the condition, C rather than x. If C is true, x is evaluated
and its value is returned; otherwise, y is evaluated and its value is
returned