Post

@PythonPr I always forget the power of the modulo (%)!
Tip: It’s the remainder operator.
- 1 % 2 == 1 → odd
- 2 % 2 == 0 → even
Real-world use cases include zebra striping, cron jobs, carousel wraps, pagination, a/b buckets, angles and more!
What’s your favorite use case?
English

@PythonPr Ans. B. Odd
x % 2 is x modulo 2. The result of the operation is the remainder of x divided by 2.
If x is odd, x % 2 -> 1;
If x is even, x % 2 -> 0;
Since x = 5 is odd, x % 2 != 0.
English

@PythonPr Python explainers like this create a more welcoming learning space,
English

@PythonPr B. It goes off the remainder since the operation is 5 mod 2 and not 5 divide 2
English
































