4 - Learn Python, Conditional instructions

in #programming4 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.16
TRX 0.16
JST 0.031
BTC 59128.17
ETH 2522.40
USDT 1.00
SBD 2.48