> For the complete documentation index, see [llms.txt](https://university-west.gitbook.io/programming-paradigms/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://university-west.gitbook.io/programming-paradigms/programming-fundamentals/datatypes/primitive-datatypes/boolean.md).

# Boolean

The Boolean data type, named after the mathematician George Boole, is a fundamental concept in computer programming and computer science. It represents a logical entity that can have one of two values: `true` or `false`. These values are used to perform logical operations, most commonly in conditional statements and loops, allowing for the control flow of a program to be altered based on certain conditions.

#### Characteristics of the Boolean Data Type:

* **Binary Values:** A Boolean variable can only hold one of two possible values: `true` or `false`. This binary nature makes it ideal for decisions that are essentially yes/no or on/off.
* **Logical Operations:** Booleans are primarily used with logical operators such as AND (`&&` or `AND`), OR (`||` or `OR`), NOT (`!` or `NOT`), which operate on Boolean values to produce a Boolean result. These operations are foundational to constructing complex conditions in programming.
* **Control Structures:** In programming, control structures like `if` statements, `while` loops, and `for` loops often rely on Boolean expressions to determine the flow of execution. For example, an `if` statement might execute a block of code only if a certain Boolean expression evaluates to `true`.
* **Storage Efficiency:** Because Boolean values are so simple, they require very little storage space, typically one bit. However, the actual size of a Boolean data type can depend on the programming language and its implementation.

#### Usage in Different Programming Languages:

While the concept of Boolean remains consistent across programming languages, the implementation and syntax can vary:

* **In Python:** Booleans are written as `True` and `False`, with capital 'T' and 'F'.
* **In Java and C++:** Booleans are declared with the `boolean` keyword, and the values are `true` and `false`, all in lowercase.
* **In JavaScript:** Similar to Java and C++, but with the flexibility of being dynamically typed.

#### Example in Python:

```python
is_raining = True
if is_raining:
    print("Don't forget to bring an umbrella!")
```

In this Python example, `is_raining` is a Boolean variable that determines whether the message is printed based on its truth value.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://university-west.gitbook.io/programming-paradigms/programming-fundamentals/datatypes/primitive-datatypes/boolean.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
