Note on Arithmetic and Logical Operators in Python
1. Arithmetic Operators
Arithmetic operators in Python are used to perform basic mathematical operations. They work on
numeric values (integers, floats, etc.).
Types of Arithmetic Operators
1. Addition (+): Adds two values.
2. Subtraction (-): Subtracts second value from first.
3. Multiplication (*): Multiplies two values.
4. Division (/): Performs true division and returns a float.
5. Floor Division (//): Returns the integer part of division (rounds down).
6. Modulus (%): Gives the remainder of division.
7. Exponentiation (**): Raises the first number to the power of the second.
2. Logical Operators
Logical operators are used to combine multiple conditions. They return either True or False.
Types of Logical Operators
1. and: Returns True if all conditions are true.
2. or: Returns True if any one condition is true.
3. not: Reverses the logical state of its operand.
Key Points
- Arithmetic operators deal with numbers.
- Logical operators deal with conditions (True/False).
- Logical operators are mostly used in decision-making (if-else statements).