DEMO 2: Let's review writing if statements with proper indentation.

If statements, or conditionals, start with a test that compares a test variable to a test value. If the test statement is true, the code indented underneath runs. If the test statement is not true, the indented code is skipped and the rest of the program runs. An indent is 4 spaces, and properly indented lines will show a ···· before the line of code!

  • Click Run and follow the on-stage instructions before clicking Submit and Next to move on.

To navigate the page using the TAB key, first press ESC to exit the code editor.

# THIS ACTIVITY IS IN PREVIEW ONLY MODE
  • Run Code
  • Submit Work
  • Next Activity
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)