Summary

Completed

By using test expressions, otherwise known as Boolean expressions, you can conditionally run Python code. They're commonly used in Python to "make decisions" about what should happen next while a program is running. In the earlier units, you wrote test expressions as part of if, else, and elif statements, and you further fine-tuned your conditions by using the operators and and or.

Boolean expressions and statements are a key part of creating complex Python programs, where you want your code to run only under certain conditions.

Here are some of the essentials you now know about conditional logic:

  • Booleans can have one of two values, True or False.
  • if, else, and elif statements can be used to run code under specific conditions.
  • and and or operators can be used to combine test expressions and create more complex conditions.

With these tools, you should feel ready to write more complex code blocks in Python.