1.6 Conditionals or Decisions (if)

Useage Example 1

x = 6

if x < 5:
    print('Less than 5.')
elif x > 5 :
    print('More than 5.')
else:
    print('Equal to 5!')
# More than 5.

Useage Example 2

a, b = .3, .6

if a > .5 and b > .5:
    print('Both over half.')
elif a > .5 or b > .5:
    print('One over half.')
elif a == .5 or b == .5:
    print('One (or both) equal to half.')
else:
    print('Both below half.')
# One over half.

Note the following:

Meaning Math Symbol Python Symbols
Less than < <
Greater than > >
Less than or equal <=
Greater than or equal >=
Equals = ==
Not equal !=

One liners (Ternary Conditionals)

You may also use the if as follows:

x = 6
print('Less than 5.') if x < 5 else print('More than 5.')
# More than 5.