Beginner · Conditions · 62 of 264
Divisible?
Read two whole numbers a and b (b is not 0). Say whether a divides exactly by b.
Input: a and b, one per line. Output: yes or no
Examples
Input
10 5
Output
yes
Input
10 3
Output
no
Input
0 7
Output
yes
One more test checks other inputs when you press Check.
Stuck? The idea behind conditions
An if statement runs its indented lines only when the condition is true; elif tries another condition; else catches everything left.
Compare with == (equal), != (not equal), <, <=, >, >=, and join conditions with and, or, not.
n = int(input())
if n > 0:
print("positive")
elif n < 0:
print("negative")
else:
print("zero")Watch for: = gives a value, == compares. And the order of elif matters: the first true one wins, so test the narrow case first.