Skip to content
dreamcode
dreamcode
Map
Boolean operators
Lesson 11 of 77
+15 XP on finish
PYTHON BASICSChapter 2 · Conditionals and logic

Combining checks

Combine boolean values using logical operators: and (True if both sides are True), or (True if at least one side is True), and not (flips True to False and vice versa).

Worked example

How it reads

  • day == "Sunday" and temp > 20 requires both statements to be True
  • not (temp < 10) returns True if temp is 10 or greater
Cloud tip: Use parentheses to group logical checks and make the order of comparison clear.
main.py
PYTHON
real Python, runs in your browser
Console
Run your code to see its output here.
YOUR TURN

Add raining = False and include not raining in the check, then set lights_off = True so the program prints Stars visible.

Press Run to check your work.