Tag Archives: #Since

#mastery17 Use of “elif” with a conditional

This is similar to an “else” but instead of doing something if the first condition is not fulfiled, this will make another condition in case the first one isnt fulfiled. For example:

num=2

if (num>3):

print (“Hello”) #  wont print this because the condition is not fulfiled (false)… this line must be idented so it can be part of the “if”

elif (num==2):

print (“Goodbye”) # the condition wasnt fulfiled the “elif” will take place and it’ll print Goodbye… this line must be idented so it can be part of the “elif”

#mastery16 Use of “else” with a conditional

This is the alternate ending to an if function. If the condition is not fulfiled you put an “else” and it will do what is inside of that “else” for example:

num=2

if (num>3):

print(“hello”) wont print this because the condition is not fulfiled (false)… this line must be idented so it can be part of the “if”

else :

print (“goodbye”) the condition wasnt fulfiled the “else” will take place and it’ll print goodbye… this line must be idented so it can be part of the “else”

This program will show the user:

goodbye