how to use if else statement in python code example

Example 1: if else python

# IF ELSE ELIF 

print('What is age?')
age = int(input('number:')) # user gives number as input
if age > 18:
    print('go ahead drive')
elif age == 18:
    print('come personaly for test')
else:
    print('still underage')

Example 2: if syntax in python

variable_name = input("y/n? >> ")
if variable_name == "y":
	print("That's good! :) ")
# note the double equal signs. only a single equal sign will receive a Syntax error blah blah blah message.
elif variable_name == "n":
    print("That's bad! :( ")
else:
    print("You blow up for not following my instructions. Detention forever and get lost!")

Example 3: else if python

if expression1:
   statement(s)
elif expression2:
   statement(s)
elif expression3:
   statement(s)
else:
   statement(s)

Example 4: else if python

if (condion):
   result
    
elif (condition):
   results
    
else:
   result