Mark As Completed Discussion

One Pager Cheat Sheet

  • In this lesson we will learn about controlling the flow of execution of programs in Javascript by using if/else and try/catch statements.
  • If/Else and Try/Catch statements 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 if keyword is used to execute a certain task, by evaluating an expression and then executing the statement under the condition that the expression evaluates to True.
  • We can use if-elif-else to create multiple if statements and add conditions to our code.
  • It is important to note that an if condition must exist for any elif or else clauses to work.
  • No limit exists to the number of statements and code blocks (if, elif, else, etc.) that can be used under an if block.
  • The required colon (:) is missing from the if statements and else blocks in the code.
  • Using a try/catch statement allows us to handle errors by specifying what to do when an error occurs during the execution of a program.
  • Try/Catch statements in Python use the try and except keywords to allow programs to continue running, even when an exception is raised by the try block.
  • No except block can be called unless a try block has been declared and an exception has been raised, as the except block will not be executed without it.
  • The try block will always be executed and will return the value of 1, as the except block cannot be reached without a preceding try block.
  • We learned how to use if/else and try/catch statements to control program execution and handle any uncertain conditions that may arise when creating complex applications such as those used in artificial intelligence.