One Pager Cheat Sheet
- In this lesson we will learn about controlling the flow of execution of programs in Javascript by using
if/elseandtry/catchstatements. If/ElseandTry/Catchstatements are used to control the flow of a program and specify different code execution based on specified conditions and errors/exceptions.- Using If/Else Statements can control the flow of a program and automatically produce the desired output
depending on certain conditions. - Python's
ifkeyword is used to execute a certain task, by evaluating an expression and then executing the statement under the condition that the expression evaluates toTrue. - We can use
if-elif-elseto create multipleifstatements and add conditions to our code. - It is important to note that an
ifcondition must exist for anyeliforelseclauses to work. - No limit exists to the number of statements and code blocks (
if,elif,else, etc.) that can be used under anifblock. - The required colon (
:) is missing from theifstatements andelseblocks in the code. - Using a
try/catchstatement allows us to handle errors by specifying what to do when an error occurs during the execution of a program. Try/Catch statements in Pythonuse thetryandexceptkeywords to allow programs to continue running, even when an exception is raised by thetryblock.- No except block can be called unless a
tryblock has been declared and an exception has been raised, as theexceptblock will not be executed without it. - The
tryblock will always be executed and will return the value of 1, as theexceptblock cannot be reached without a precedingtryblock. - We learned how to use
if/elseandtry/catchstatements to control program execution and handle any uncertain conditions that may arise when creating complex applications such as those used in artificial intelligence.


