**Equals:** $a == b$

**Not Equals:** $a != b$

**Less than:** $a < b$

**Less than or equal to:** $a <= b$

**Greater than:** $a > b$

**Greater than or equal to:** $a >= b$

**AND:** $x>=5$ **and** $x<=10 \approx x \in [5,10]$ (conjunction)

**OR:** $x>5$ **or** $x=<1 \approx \left[
\begin{gathered}
x \le 1; \\
x > 5, \\
\end{gathered}
\right.$ (disjunction)

**NOT:** **not** $x>1 \approx x\le 1$ (negation)

**Logical operators return True (if the condition is satisfied) or False (otherwise).**

In [1]:

```
print(1 == True)
print(False == 0)
```

In [ ]:

```
1==1
```

In [ ]:

```
not 1==1 # it is kind of negation
```

In [ ]:

```
2>3
```

Out[ ]:

In [ ]:

```
1==1 or 2>3 # it is kind of disjunction
```

Out[ ]:

In [ ]:

```
11 and 2>3 # it is kind of conjunction
```

Out[ ]:

In [3]:

```
isEven = 9 % 2 == 0
print(isEven)
if isEven == True:
print('even')
else:
print('odd')
```

In [ ]:

```
int(isEven), int(not isEven)
```

Out[ ]:

In [2]:

```
1 + int(True), True + False
```

Out[2]:

In [ ]:

```
x = 10
y = 20
# standart indentation
if y > x: # true
print("y is greater than x")
```

In [ ]:

```
# short
if y > x: print("y is greater than x"); print(""); y = y+x;
```

In [ ]:

```
x = int(input("x="))
y = int(input("y="))
if x == y:
print("x and y are equal")
else:
print("x and y are not equal")
```

In [ ]:

```
x = int(input("x="))
y = int(input("y="))
if y > x:
print("y is greater than x")
elif x > y:
print("x is greater than y")
else:
print("x and y are equal")
```

In [ ]:

```
x = int(input("x="))
y = int(input("y="))
```

In [ ]:

```
print("X") if x > y else print("Y") #one line if statement
if x > y:
print ("X")
else:
print ("Y")
```

In [ ]:

```
print("X") if x > y else print("equal") if x == y else print("Y") ### more complex one line if statement
```

In [5]:

```
a,b,c,d = 1,2,3,4
```

In [ ]:

```
if a < b or a < c:
print("At least one of the conditions is True")
```

In [ ]:

```
if a < b < c:
print("Condition satisfied")
```

In [ ]:

```
if a < b and a < c:
print("All conditions are True")
```

In [ ]:

```
# first_condition = c<b or d<a
if not (c<b or d<a) and (a<b):
print("Complex conditions example is False")
```

In [ ]:

```
```

You get coordinates of two chess board cells: x1, y1, x2, y2.

Determine if a knight can reach the cell [x2, y2] in a single move, starting from the cell [x1, y1].

A knight's moves are the following (two cells in one direction, then one cell in a perpendicular direction):

```
...*.*..
..*...*.
....K...
..*...*.
...*.*..
```

Print "YES" if the knight can reach the cell [x2, y2] in a single move. Otherwise, print "NO".

In [ ]:

```
x1 = int(input())
y1 = int(input())
x2 = int(input())
y2 = int(input())
```

A simple loop:

In [ ]:

```
n = 10
i = 1
while i <= n:
print(i)
i = i + 1
```

A loop for entering sequences of numbers terminated by 0.

In [ ]:

```
current = int(input())
minimum = current
while current != 0:
# your code
current = int(input())
print(minimum)
```

Use the previous loop to make a program that finds a minimum value of a sequence.

Use the same loop to make a program that computes a sum of a sequence.

An alternative way of stopping the loop is to use the keyword `break`

.

The keyword `continue`

stops the current iteration of the loop and starts the next one.

In [3]:

```
i = 1
while i < 4:
print(i)
i = i + 1
if i > 4:
break
print('After {}'.format(i-1))
else:
print('There is an else')
```

In [ ]:

```
i = 0
while i <= 20:
i = i + 1
if i % 3 == 0:
continue
print('{} is not divisible by 3'.format(i))
```