This is an example of a simple conditions sequence, only including a if…else conditions
It works by checking the variable name and IF it is equal than it prints the statement, ESLE if its not equal then it will print the "You may not enter"
Nick may enter.
This is an example of a more advanced conditions sequence, it includes if…elself…else conditions
It works by checking the variable day and IF it is equal to Wednesday or Monday it "prints Take 440"
ESLE IF its equal to Saturday then it will print the "Go to gym"
ESLE IF its equal to Thursday hen it will print the "Blah Blah"
Lastly if its equal to anything else it will print "Go to the lib"
Today is Friday. Go to the lib
This is an example of a switch its like a if…else condition but instead of you doing the == condistion yourself it does it automactically
Best used to replace a long if-elseif-else
May be cleaner in some scenarios.
Use the switch statement to select one of many blocks of code to be executed.
Once execution of that block is finished, since there is a break statement, the code will not run to the next case and will exit the whole switch block.
If there is no match found, the block under default statement will be executed.
Today is Friday. Go to the gym.