DEMO: A conditional is a piece of code that tells your program to do a group of commands if something is true.

There are two parts of a conditional:

The Test: if·random_number·==·1:¬ This line tells your program "Test if this is equal to that".

The Commands: These lines of code come after the test and have a ····. They run if (and only if) the test is true.

  • Click Run to learn more about conditionals and when the code beneath them runs!

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)