4 - Learn Python, Conditional instructions

in #programming6 years ago

If-elif-else executes statements based on one or more conditions.
For example, let's check if the number entered is greater than or equal to 10:

a= int(input('insert number '))
if a>=10:
print('The number entered is greater than 10')
else:
print('The number is less than 10 :( ')

But it is possible that we have a block of conditions, in this case we add the elif construct:

a= int(input('insert number '))
if a>=10:
print 'The number entered is greater than 10'
elif a==0:
print a, 'is equal to zeroo!!!! '
else:
print 'The number is less than 10 :( '

Coin Marketplace

STEEM 0.06
TRX 0.29
JST 0.053
BTC 70182.35
ETH 2063.00
USDT 1.00
SBD 0.49