Explain types of operator
Answers
There are four types of operators.
- Arithmetic
- Relational
- Logical
- Assignment
- Shorthand assignment
1. Arithmetic Operators
These are operators that carry out basic operations.
+, -, *, /, //, %, ** are the arithmetic operators.
2. Relational Operators
These are operators that carry out comparisons.
<, <=, >, >=, ==, != are the relational operators.
3. Logical Operators
These are operators that can carry more than one comparison.
'and', 'not', 'or' are the logical operators.
4. Assignment Operator(s)
This operator assigns values to variables.
= carries out the assignment.
5. Shorthand assignment Operators
These are operators that carry out arithmetic calculations and assigns the value obtained to the variable.
+=, -=, *=, /=, %= are the shorthand assignment operators.
(Attachment 1 - Arithmetic, Attachment 2 - Relational, Attachment 3 - Logical, Attachment 4 - Assignment, Attachment 5 - Shorthand assignment.)