4 - Learn Python, Conditional instructions

in programming •  5 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 :( '

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!