Beginner · Conditions · 63 of 264
Can it be a triangle?
Three lengths make a triangle when each one is smaller than the sum of the other two.
Input: three positive whole numbers, one per line. Output: yes or no
Examples
Input
3 4 5
Output
yes
Input
1 2 3
Output
no
Input
10 1 1
Output
no
2 more tests check 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.