Nested if-else query

if a%5==0:
print(“divisible by 5”)

What does this statement contain if a%5==0? I know that if a is divisible by 5 but Why there is ==0?

hey @premprakash.cr ,
% represents to get the remainder.
so if i%5 == 0 , means if the remainder is 0.
But the point is , if you just use like
if i%5 : then something.
This will not work , as if statements requires a True condition to work forward.
and as this will return 0 , which in boolean is False. Hence , it would be if False. Then you can understand that it wont work.
This is the reason that we use == 0 with this.

Thank You and Happy Learning :slightly_smiling_face:.

1 Like

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.