Theory

Conditions allow your program to make decisions.

if age >= 18:
print("Adult")
else:
print("Minor")

Comparison operators:
== equal (равно)
!= not equal (не равно)
> greater than (больше)
< less than (меньше)
>= greater or equal (больше или равно)
<= less or equal (меньше или равно)

IMPORTANT: Use indentation (4 spaces) after if/else!

Exercises in this lesson

2

If/Else

Variable score = 75. If score >= 60, display "Pass". Otherwise, display "Fail".

Easy Points: 15
3

Number Check

Variable number = 0. If number > 0, print "Positive". If number < 0, print "Negative". If number == 0, print "Zero".

Medium Points: 20
4

Even or Odd

Variable n = 7. Check if n is even or odd. If even, print "Even". If odd, print "Odd". Hint: Use n % 2. If n % 2 == 0, the number is even.

Medium Points: 20
Solve in the playground
Next lesson: Loops →