jeudi 6 août 2020

Trying to solve the conditional statement question getting the answer right but have a Query in my mind

x = 2

if x < 5:
    print("X is Smaller")

elif x < 10:
    print("X is Medium")

else:
    print("X is Bigger")

print("All Done")

OUTPUT:

X is Smaller
All Done

My question is x = 2 is smaller than 5 as well as 10. Then Why the output is the if statement i.e "X is smaller"??? Why not elif statement i.e "X is Medium" ??

Aucun commentaire:

Enregistrer un commentaire