operators Flashcards
Escape Sequences: \n, \r, ', ", \, \b, \f, \t, \v, \uXXXX or \UXXXXXXXX
\n: Newline character.
\r: Carriage return character.
': Single quote.
": Double quote.
\: Backslash.
\b: Backspace.
\f: Form feed.
\t: Tab.
\v: Vertical tab.
\uXXXX or \UXXXXXXXX: Unicode escape sequences.
Arithmetic Operators: +, -, *, /, %, **, //
+ Addition
- Subtraction
- Multiplication
/ Division
% Modulus (remainder after division)
** Exponentiation (e.g., 2**3 means 2 to the power of 3)
// Floor Division (returns the quotient, discarding any remainder)
Comparison Operators: ==, !=, <, >, <=, >=
== Equal to
!= Not equal to
< Less than
> Greater than
<= Less than or equal to
> = Greater than or equal to
Assignment Operators: =, +=, -=, *=, /=, %=, **=, //=
= Assignment
+= Add and assign
-= Subtract and assign
*= Multiply and assign
/= Divide and assign
%= Modulus and assign
**= Exponentiation and assign
//= Floor Division and assign
‘and’ operator
returns true if both statements are true
‘or’ operator
returns true if one of the statements is true
‘not’ operator
reverse the result, returns false if the result is true
Bitwise Operators:
& : sets each bit to 1 if both bits are 1
^ : sets each bit to 1 if only one or two bits is 1
~ : inverts all the bits
«_space; : shift left by pushing zeros in from the right and let the leftmost bits fall off
> > : shift right by pushing copies of the leftmost bit in from the left, and let the rightmost bits fall off
: sets each bit to 1 if one of two bits is 1
Identity operators:
- Is true if the operands are identical objects
- Is not true if the operands are not identical objects