IF....ELSE
Learning Objective:
Be able to use 'If else' to create Conditional Statements
Understand how to use Comparative Operators (see below)
Be able to use the correct indentation to show code ownership
If you typed h when asked if you were happy or sad the program would print:
I am so pleased you are happy
If you typed s (or any other letter) the program would print
I am very sorry you are sad today
Note that both print lines are indented (don't start on far left) this means they are only run if the condition above them is met.
I am so pleased you are happy
If you typed s (or any other letter) the program would print
I am very sorry you are sad today
Note that both print lines are indented (don't start on far left) this means they are only run if the condition above them is met.
ADVENTURE GAME:
If event one is equal to letter s:
print("One outcome")
else:
print("different outcome")
Note if the user had typed using a capital S then it would not have been equal
print("One outcome")
else:
print("different outcome")
Note if the user had typed using a capital S then it would not have been equal