Posts

Showing posts with the label Operators in Python

Operators in Python

Python operators are symbols that perform operations on variables and values. Here's a breakdown of the main types: ### 1. **Arithmetic Operators**    - `+`: Addition    - `-`: Subtraction    - `*`: Multiplication    - `/`: Division (returns float)    - `%`: Modulus (remainder)    - `**`: Exponentiation (e.g., `2 ** 3 = 8`)    - `//`: Floor Division (returns integer, rounds down). ### 2. **Comparison (Relational) Operators**    - `==`: Equal to    - `!=`: Not equal to    - `>`: Greater than    - `<`: Less than    - `>=`: Greater than or equal to    - `<=`: Less than or equal to. ### 3. **Logical Operators**    - `and`: True if both operands are true.    - `or`: True if at least one operand is true.    - `not`: Inverts the boolean value (e.g., `not True → False`). ### 4. **Assignment Operators**    - `=`: Ass...