Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

README.md

Boolean and Logic Exercises

Booleans represent True/False values and are fundamental to all conditional logic in programming.

Key Concepts

Boolean Values

  • True and False (note the capitalization)
  • Result of comparisons: 5 > 3 returns True
  • Result of logical operations

Logical Operators

  • and - both must be True
  • or - at least one must be True
  • not - reverses the value

Truthiness in Python

Values that are considered False:

  • False, None, 0, 0.0, "", [], {}, set()

Everything else is considered True.

Comparison Operators

  • == equal, != not equal
  • <, <=, >, >=
  • is (identity), in (membership)

Tips

  • Use parentheses for complex conditions
  • Take advantage of short-circuit evaluation
  • Remember that = assigns, == compares
  • Empty collections are falsy, non-empty are truthy