Operators Flashcards
+
add
*
multiply
-
subtract
**
Exponent - Performs exponential (power) calculation on operators
/
Division
<
less than
%
Modulus - Divides left hand operand by right hand operand and returns remainder
>
greater than
<=
less than or equal to
> =
greater than or equal to
==
equal to
!=
not equal to
( )
parathesis
//
Floor Division - The division of operands where any digit after decimal point are removed.
9//2 = 4
( )
parenthesis for strings ??
@
?
{ }
parenthesis for ??
[ ]
parenthesis for lists ??
,
separates statements with a space
strings, numbers, booleans, variables etc
=
equals
.
signifies a command/ function/ method
i.e. variable.read var1.append
+=
a = a + ?
;
; is a redundant symbol in Python.
However it is often seen because it is a common syntax of other languages.
It is therefore used by habit by programmers.
It basically does nothing, it does not affect code in anyway.
-=
a = a - ?
*=
a = a * ?
/=
a = a / ?
:
always add at end of first line of any sub-routine.
i.e. def, if, elif, else etc
//=
a = a //?
%=
a = a % ?
**=
a = a ** ?
is
object identity
Evaluates to true if the variables on either side of the operator point to the same object and false otherwise.
x is y, here is results in 1 if id(x) equals id(y).
is not
negate object identity
Evaluates to false if the variables on either side of the operator point to the same object and true otherwise.
x is not y, here is not results in 1 if id(x) is not equal to id(y).
and
Called Logical AND operator. If both the operands are true then then condition becomes true.
or
Called Logical OR operator. If both or either the operands are true then then condition becomes true.
not
Called Logical NOT Operator. Use to reverses the logical state of its operand. If a condition is true then Logical NOT operator will make false.
i.e. not(a and b) = not (true) = not true = false
in
Evaluates to true if it finds a variable in the specified sequence and false otherwise.
x in y, here in results in a 1 if x is a member of sequence y.
not in
Evaluates to true if it does not finds a variable in the specified sequence and false otherwise.
x not in y, here not in results in a 1 if x is not a member of sequence y.
< >
redundant legacy operator.
use (!=) is not equal to