Question
what are six relational operators used in python?
Answers
GPT-4o mini
In Python, relational operators (also known as comparison operators) are used to compare two values. Here are six common relational operators:
1. **Equal to (`==`)**: Checks if two values are equal.
```python
a == b
```
2. **Not equal to (`!=`)**: Checks if two values are not equal.
```python
a != b
```
3. **Greater than (`>`)**: Checks if the left value is greater than the right value.
```python
a > b
```
4. **Less than (`<`)**: Checks if the left value is less than the right value.
```python
a < b
```
5. **Greater than or equal to (`>=`)**: Checks if the left value is greater than or equal to the right value.
```python
a >= b
```
6. **Less than or equal to (`<=`)**: Checks if the left value is less than or equal to the right value.
```python
a <= b
```
These operators return a Boolean value (`True` or `False`) based on the comparison.
1. **Equal to (`==`)**: Checks if two values are equal.
```python
a == b
```
2. **Not equal to (`!=`)**: Checks if two values are not equal.
```python
a != b
```
3. **Greater than (`>`)**: Checks if the left value is greater than the right value.
```python
a > b
```
4. **Less than (`<`)**: Checks if the left value is less than the right value.
```python
a < b
```
5. **Greater than or equal to (`>=`)**: Checks if the left value is greater than or equal to the right value.
```python
a >= b
```
6. **Less than or equal to (`<=`)**: Checks if the left value is less than or equal to the right value.
```python
a <= b
```
These operators return a Boolean value (`True` or `False`) based on the comparison.