Operators - Tokens that trigger computation when applied to variables and other objects in a expression. Variable and expression to which the operators are applied are called operands.
Example:- 2+3 here 2,3 are operands and + is operator.
1. Unary Operators - It operates on only one operand. Example:-
Operator | Name | Example |
+ | Unary Plus | +10, 23E+2 |
- | Unary Minus | -4.3, -2.3E-1 |
~ | Bitwise complement | ~3 |
not | Logical negation | not 2 |
2. Binary Operators - It requires two operators to operate upon.
Operator | Name | Example |
+ | Addition | 2+3 = 5 |
- | Subtraction | 2-3=-1 |
* | Multiplication | 2*3=6 |
/ | Division | 2/3 = 0.66666666 |
% | Remainder | 2%3 = 2 |
** | Exponent | 2**3 = 8 |
// | Floor division | 55//2 = 27 |
Comments
Post a Comment