Sign in

Intro to Computer Science / Unit 5: Conditionals and Boolean Logic

5.1 Booleans and Comparison Operators

3 practice questionsNot yet reviewed

Notes

A Boolean value is either True or False. Comparison operators produce Booleans.

OperatorMeaning
==equal to
!=not equal to
< >less than, greater than
<= >=less than or equal, greater than or equal
  • Use == to compare. A single = assigns a value; it does not compare.
  • Example: 7 >= 7 is True, and "cat" == "Cat" is False because strings are case sensitive.

Practice

What does print(10 != 4) display?
Which operator checks whether two values are equal?
What does print("Dog" == "dog") display?

Ready for more? Take the Unit 5 test.