Boolean Logic: Definition, Truth Tables, Operators, and Examples

Written by Coursera Staff • Updated on

Learn about Boolean logic and how it structures computing, programming, database search, and more. Explore some of the operators it uses, and what a truth table in Boolean algebra is.

[Featured Image] Learners listen to an instructor providing a lesson on Boolean logic and its role in computer science.

Key takeaways

  • Boolean logic, also known as Boolean algebra, uses three basic operators: "AND," "OR," and "NOT" to manipulate clauses and declare statements as "true" or "false."

  • Boolean logic uses truth tables, which visually display an array of truth-value expressions under different operator conditions.

  • Boolean logic works in computing by assigning "True" or "on" to "1" and "False" or "off" to "0."

Discover more about Boolean logic, its basic operations, and how it underpins computing and engineering disciplines. If you're ready to start building in-demand programming skills, try the Microsoft Full-Stack Developer Professional Certificate. In nine months, you'll gain skills in object-oriented programming languages like C# and start building real-world programs.

What is Boolean logic?

Boolean logic is a form of algebra that uses truth values (true or false) to clarify complex subjects. It provides instructions based on the logical relationships among operands, the objects of the mathematical operation. Boolean logic has many applications in programming, computing, circuitry, and database retrieval. For example, if you take the sentence:

It is snowing.

You can then look outside to see whether it is snowing. The statement (known as a proposition in Boolean logic) is either true or false. In Boolean logic, you have no middle ground [1].

Who invented Boolean algebra?

Boolean algebra is named after 19th-century British mathematician and logician George Boole. Boole wanted to formally create a system to categorize the logic of his philosophical predecessors, namely Aristotle’s syllogistic logic [2].

What are the basic Boolean operators?

Operators are what Boolean logic uses to perform functions on operands. The basic operations of Boolean algebra are:

  • AND

  • OR

  • NOT

These operators in Boolean algebra are what allow for complex statements to arise, even though the fundamental expressions of Boolean logic are true and false. Explore each basic operator to understand how to form Boolean expressions and how to perform a basic database search using each operator. In this example, you're searching for books using a library database.

AND

The AND operator allows you to combine two clauses together, only giving a "true" statement if both clauses return true. You walk up to the library and can't remember the exact title of the book you want to read. However, you remember the topic is "love." So, you search for "love", but hundreds of books on the subject come up. That said, if you also knew the author of the book, you could use the AND operator to search, using:

love AND dr grace alberta

This search will return "true" if Dr. Grace Alberta has a book on love. Note that many, but not all, databases automatically place the AND operator in your search. So your search may simply look like:

love dr grace alberta

OR

The OR operator allows you to expand what can be true by only needing one clause to be true to return a true statement. In the context of a database search, you may want to research different but related concepts. Say you want a more general search on books about love, care, and happiness. You can connect these clauses using the OR operator as follows:

love OR care OR happiness

With this search, the database returns many books on those topics because you've specified that the database will return a true value (your search) using any of those terms.

NOT

The NOT operator allows you to limit what is true by excluding values. In your library search, say you wanted to find books on love but were not interested in romantic love between couples or about marriage. To complete this search using the NOT operator would look like:

love NOT marriage NOT couples

With this search, you've excluded search terms by declaring that anything about love is true, except search results dealing with married couples, which are false.

Read more: How to Learn Data Structures and Algorithms: A Basic Guide

What is a truth table in Boolean algebra?

A truth table in Boolean algebra is a way of visually demonstrating the results of Boolean expressions under certain operator conditions. The simplest truth table in Boolean algebra shows the value of expressions [3]:

ExpressionTruth value
XTrue
YFalse

Truth tables, however, show how different operators affect truth value. The following truth table shows the expressions x and y under the operators AND:

ExpressionTruth value
XFalse
YFalse
X AND YTrue
ZFalse

In this example, the Boolean is true only when both X AND Y are present.

How has Boolean logic impacted computing?

In computing, Boolean logic assigns "True" or "on" to "1" and "False" or "off" to "0" and was pivotal in the development of computing. This is due to:

  • The application of Boolean logic eventually helped bring about the first digital computer, thanks to the work of Claude Shannon in the 1930s.

  • By combining the logic of networking with the representation of "on" and "off" in electrical engineering and circuitry, the design of logic gates led to the creation of the central processing unit (CPU) [4]. The logic gate of a CPU allows high-voltage wires to represent "1" while low-voltage wires take on "0," and a semiconductor calculates the logic gate's output voltage.

  • This calculated voltage is how a CPU processes computing tasks. To handle these complex tasks, CPUs have millions of logic gates made from transistors that communicate the "on" and "off" states.

Boolean algebra vs. Boolean search

Boolean algebra is a branch of mathematics that uses binary algebra, meaning that each variable is either true (1) or false (0). However, Boolean search uses Boolean operators and logic to assist you in specifying or widening your search of a database. Boolean algebra has many applications beyond just Boolean search, with fields such as electrical engineering, computing, and economics depending on its logic.

What are some Boolean logic examples?

Beyond its in-depth application in computing and circuitry, Boolean logic governs many aspects of modern life, including medicine, finance, and data science. Some other examples of Boolean logic include [5]:

  • Password analysis: When logging into a website or other authentication system, the algorithm checks whether your password input is "true" or "false".

  • Data science: When filtering data, you use logical conditions to display the data you want to see.

  • Programming: When developing software, you can use Boolean statements to terminate or trigger a process with statements like "if," "while," "for," and "else," depending on the programming language you are using.

  • Data storage: Data storage technology uses binary code to store and retrieve data like photos, videos, and files. Logic gates help store information and allow you to access it again through a similar pathway.

Explore our free resources for programmers

Subscribe to Career Chat on LinkedIn to get weekly updates on popular skills, tools, and certifications in software development. Build or refresh your coding skills with our other free resources:

Accelerate your career growth with a Coursera Plus subscription. When you enroll in either the monthly or annual option, you’ll get access to over 10,000 courses.

  • Navigate your career path in tech with 15+ all-new courses from Microsoft

    Microsoft Bundle-Tech

Article sources

1. 

Lotame. “Back to Basics: What is Boolean Logic?, https://www.lotame.com/resources/what-is-boolean-logic/.” Accessed June 30, 2026.

Updated on
Written by:

Editorial Team

Coursera’s editorial team is comprised of highly experienced professional editors, writers, and fact...

This content has been made available for informational purposes only. Learners are advised to conduct additional research to ensure that courses and other credentials pursued meet their personal, professional, and financial goals.