0
Explain meaning
Please someone explain to me what 'if not i%2==0' is and how it's used
4 Answers
+ 4
From the use of 'i' I assume that this was a condition in a "for loop", more specifically, one designed to find whether a number in the list or string literal is even or not. If this is the case, remember that the "%" operator divides the left operand (value) by the right operand (divisor) but returns the remainder of the division. In the case you just showed, it will divide any value by 2 and if it is even, it should return the value of zero.
I really hope this helps đ...
EDIT: The presence of "not" before that condition indicates that it is checking if the value is "not" even.
0
Hello! remember (or look for) from a math course, in which cases the remainder of dividing a number by two is zero?
0
'If i%2==0' , % is modullo which returns the remainder when i is divided by 2. So each time i is divided by 2 and the remainder is zero , this 'i' should be only even numbers. But the 'not' before the statement makes it false. So 'if i % 2 == 0 ' is true
Not ' if i % 2 == 0' is false. Therefore 'i' should be odd numbers
0
i%2=0 separately means that 'i' is an even number
(because it is divisible by 2 or in another word it has no remainder when you divide it by 2)
And when you have "if i%2==0", it means to check if i%2=0 is true or not
And finally with having "not" before it, if condition will returns true only if 'i' is not divisible by 2
(not reverses condition meaning)