Answered on : 2024-01-23
1. **Modulo Operator (%):**
- The modulo operator in Python (% symbol) calculates the remainder when one number is divided by another. It is useful for tasks like checking if a number is even or odd.
- Example: `5 % 2` returns `1` because 5 divided by 2 is 2 with a remainder of 1.
2. **divmod() Function:**
- The divmod() function takes two numbers and returns a tuple containing their quotient and remainder.
- Example: `divmod(8, 3)` returns `(2, 2)` because 8 divided by 3 is 2 with a remainder of 2.