Python Common Operators Flashcards
Add two numbers.
Join two strings together.
What’s its name and operator?
Plus
+
Subtract a number from another.
Can’t use for string.
What’s its name and operator?
Minus
-
Multiply two numbers.
Make copies of a string.
What’s its name and operator?
Times
*
Divide one number by another.
Can’t use for strings.
What’s its name and operator?
Divide
/
Give the remainder when dividing the left number by the right number.
Formatting operator for string in Python2.
What’s its name and operator?
Remainder
%
x**y means raise x to the power of y.
Can’t use for string.
What’s its name and operator?
Power
**
Assign the value on the right to the variable on the left.
What’s its name and operator?
Assignment
=
Is the left side equal to the right side? True if so; is False otherwise.
What’s its name and operator?
Equality
==
Is the left side not equal to the right side? True if so; is False otherwise.
What’s its name and operator?
Not equal
!=
Is the left side greater than the right side?
What’s its name and operator?
Greater than
>
Is the left side less than the right side?
What’s its name and operator?
Less than
Are both left and right true? Usually for complex conditions where you want to do something if everything is true.
What’s its name and operator?
And
&
and
Is either left or right true? Usually for complex conditions where you want at least one thing to be true.
What’s its name and operator?
Or
|
or