# Boolean or Bool

## Description

* **`true`** or **`false`**
* Represented also as **`1`** (true) or **`0`** (false)
* Whether it’s capitalized depends on the language
* Great for control and sensors

**Examples:**

*Processing:*

```java
boolean lightOn = false;
```

*C#*

```csharp
bool lightOn = false;
```

*JavaScript*

```javascript
var gameOver = true;
```

&#x20; *Python:*

```python
gameOver = False
```

## Shortcut

Using an exclamation mark ( `!` ) at the beginning of a boolean variable name is short for “the opposite” of the variable

{% hint style="warning" %}
This does **not** update the variable.
{% endhint %}

**Examples:**

*Processing and Java-based example:*

```java
boolean lightOn = false;

println(lightOn); // Prints “false” to console
println(!lightOn); // Prints “true” to console

```

*C# example:*

```csharp
bool lightOn = false;

print(lightOn); // Prints “false” to console
print(!lightOn); // Prints “true” to console

```

{% hint style="warning" %}
This "shortcut" might not exist in Python.
{% endhint %}


---

# Agent Instructions: 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:

```
GET https://hopemoore.gitbook.io/coding-for-creatives-spring-2021/glossary-and-terms/variables/data-types/boolean-or-bool.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
