โš–๏ธ Boolean

5th Grade ๐Ÿ’ป Coding

A Boolean is a type of data that has only two possible values: true or false. In Python you write them as `True` and `False`, with a capital letter.

Free ยท US Letter ยท no sign-up
Google Classroom Save to Pinterest Email me

The name comes from George Boole, a 19th-century English mathematician who studied the math of true and false โ€” โ€œand,โ€ โ€œorโ€ and โ€œnot.โ€ About a hundred years later, his ideas became a foundation of computing. Every comparison, like 7 > 5, gives back a Boolean value: True.

Boolean variables are especially useful for keeping track of a state: โ€œIs the game over?โ€, โ€œIs the character jumping right now?โ€, โ€œIs the door open?โ€ In Scratch, Boolean blocks are shaped like pointy hexagons, and they fit exactly into the slot of a condition.

For example

  • A game has a variable game_over = False, and when the lives run out it switches to True.
  • The question โ€œIs today Saturday?โ€ is Boolean โ€” the answer can only be yes or no.
  • A light switch is like a Boolean value: on or off, with no third setting in between.

๐Ÿ“Œ Remember: Boolean = only two states: True or False, like a switch.

Quick quiz

  1. How many values can a Boolean have?

  2. Who is the Boolean named after?

  3. What does 7 > 5 give back?

๐Ÿ”Ž Ask Thinkapedia another question