``````

In [1]:

def if_test(num):
if num > 100:
print('100 < num')
elif num > 50:
print('50 < num <= 100')
elif num > 0:
print('0 < num <= 50')
elif num == 0:
print('num == 0')
else:
print('num < 0')

``````
``````

In [2]:

if_test(1000)

``````
``````

100 < num

``````
``````

In [3]:

if_test(70)

``````
``````

50 < num <= 100

``````
``````

In [4]:

if_test(0)

``````
``````

num == 0

``````
``````

In [5]:

if_test(-100)

``````
``````

num < 0

``````
``````

In [6]:

def if_test2(num):
if 50 < num < 100:
print('50 < num < 100')
else:
print('num <= 50 or num >= 100')

``````
``````

In [7]:

if_test2(70)

``````
``````

50 < num < 100

``````
``````

In [8]:

if_test2(0)

``````
``````

num <= 50 or num >= 100

``````
``````

In [9]:

def if_test_in(s):
if 'a' in s:
print('a is in string')
else:
print('a is NOT in string')

``````
``````

In [10]:

if_test_in('apple')

``````
``````

a is in string

``````
``````

In [11]:

if_test_in('melon')

``````
``````

a is NOT in string

``````
``````

In [12]:

if 10:
print('True')

``````
``````

True

``````
``````

In [13]:

if [0, 1, 2]:
print('True')

``````
``````

True

``````
``````

In [14]:

print(bool(10))

``````
``````

True

``````
``````

In [15]:

print(bool(0.0))

``````
``````

False

``````
``````

In [16]:

print(bool([]))

``````
``````

False

``````
``````

In [17]:

print(bool('False'))

``````
``````

True

``````
``````

In [18]:

def if_test_list(l):
if l:
print('list is NOT empty')
else:
print('list is empty')

``````
``````

In [19]:

if_test_list([0, 1, 2])

``````
``````

list is NOT empty

``````
``````

In [20]:

if_test_list([])

``````
``````

list is empty

``````
``````

In [21]:

def if_test_and_not(num):
if num >= 0 and not num % 2 == 0:
print('num is positive odd')
else:
print('num is NOT positive odd')

``````
``````

In [22]:

if_test_and_not(5)

``````
``````

num is positive odd

``````
``````

In [23]:

if_test_and_not(10)

``````
``````

num is NOT positive odd

``````
``````

In [24]:

if_test_and_not(-10)

``````
``````

num is NOT positive odd

``````
``````

In [25]:

def if_test_and_not_or(num):
if num >= 0 and not num % 2 == 0 or num == -10:
print('num is positive odd or -10')
else:
print('num is NOT positive odd or -10')

``````
``````

In [26]:

if_test_and_not_or(5)

``````
``````

num is positive odd or -10

``````
``````

In [27]:

if_test_and_not_or(10)

``````
``````

num is NOT positive odd or -10

``````
``````

In [28]:

if_test_and_not_or(-10)

``````
``````

num is positive odd or -10

``````
``````

In [29]:

def if_test_and_backslash(num):
if num >= 0 \
and not num % 2 == 0:
print('num is positive odd')
else:
print('num is NOT positive odd')

``````
``````

In [30]:

if_test_and_backslash(5)

``````
``````

num is positive odd

``````
``````

In [31]:

def if_test_and_brackets(num):
if (num >= 0
and not num % 2 == 0):
print('num is positive odd')
else:
print('num is NOT positive odd')

``````
``````

In [32]:

if_test_and_brackets(5)

``````
``````

num is positive odd

``````