If Statements
# Let's set up a variable with the amount of money we got
money_in_pocket = 100.75
# This code will not run, because money_in_pocket is not greater than 100000
if money_in_pocket > 100000:
print('Congratulations, you can buy an Armani handkerchief')
if money_in_pocket <= 200:
print('You could use a helping hand, he\'s another $100')
money_in_pocket = money_in_pocket + 100def is_even(num):
if num % 2 == 0:
print('The number is even')
return True
# If the number was even, the function would return True
# That means that if this code would not run once the if statement's code
# goes through (remember, return stops execution)
# So this code will only run if the number was odd
print('The number is odd')
return False
is_even(6)
# The number is even
# True
is_even(19)
# The number is odd
# FalseLast updated