# Comparison operators

Type of operators that compare two values. Produce boolean as a result.

## List of comparison operators

a == b # equal a != b # not equal a < b # less than a > b # greater than a <= b # less than or equal to a >= b # greater than or equal to

## Examples

Comparison operators are used in conditional statements, loops and anywhere else where boolean is expected.

### Comparison in conditional statement

if (x > 10): print("Number is larger than 10") else: print("Number is smaller or equal to 10")

The code above will print `"Number is larger than 10"`

if the value of `x`

is an integer larger than `10`

. Otherwise, it will print `"Number is smaller or equal to 10"`

.

## Comparison in loop

a = 0 while (a != 7): print("Hi!") a = a + 1

The code above will print `"Hi!"`

seven times. `!=`

is a comparison operator.