> For the complete documentation index, see [llms.txt](https://docs.arkannis.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.arkannis.net/programming/courses/python-pcap-31-03-course/lists-tuples-and-dictionaries/comparison-operators.md).

# 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
