# Comparison Operators

## Comparison Operators

`=` - is used for assignment&#x20;

`==` - is used for comparison

```python
print(10 == 10) # Checks if 10 = 10 --> will print True

# String comparison
print('hello' == 'Hello') # Checks if hello = Hello --> will print False
```

**Comparison operators take into consideration types as well:**

```python
print(5 == '5') # Checks if 5 = '5' --> will print False

# There are also certain types that are 'truthy' (kinda true)
print(5 = 5.00) # Checks if 5 = 5.00 --> will print True
print(5 = 5.01) # Checks if 5 = 5.01 --> will print False
```

**Less then, greater then, less then or equal to, grater then or equal to:**

```python
print(5 < 10)  # Checks if 5 < 10 --> will print True
print(5 > 10)  # Checks if 5 > 10 --> will print False
print(5 <= 5)  # Checks if 5 less then or equal to 5 --> will print True
print(5 >= 10) # Checks if 5 greater then or equal to 10 --> will print False
```

**The bang operator - (Negation operator):**

```python
print(5 != 6) # Checks is 5 is NOT equal to 6 --> will print True
```

**The 'or' condition:**

```python
print('hello' == 'Hello' or 5 == 5) # Checks if one of the conditions is correct and if it is it will print True
```

**The 'and' condition:**

```python
print('hello' == 'Hello' and 5 == 5) # Checks if both conditions are correct, if they are not it will print False
```

#### To write this cleaner it is better for each condition to be wrapped in it's own paranthesis:

```python
print(('hello' == 'Hello') and (5 == 5))
```

#### Evaluation of statements:

```python
True  + True  = True
True  + False = False
False + False = False
```

**The 'not' operator:**

```python
# Not will do the oposite:
print( not False ) # Prints True
print(not True)    # Prints False
```

### All comparison operators result in a `bool` value:

* Either True
* Either False


---

# 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://docs.arkannis.net/programming/courses/python-pcap-31-03-course/lists-tuples-and-dictionaries/comparison-operators.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.
