python if else statement example
Example 1: if else python
print('What is age?')
age = int(input('number:'))
if age > 18:
print('go ahead drive')
elif age == 18:
print('come personaly for test')
else:
print('still underage')
Example 2: else if python
if expression1:
statement(s)
elif expression2:
statement(s)
elif expression3:
statement(s)
else:
statement(s)
Example 3: if else python
if condition:
result
elif condition:
result
else:
result
Example 4: else if python
name = input("What's your name? \n")
if name == "Aguy12":
print("Wait a second...")
elif name == "Aguy11":
print("Now that's definitely not true")
else:
print(f"Hello, {name}!")
Example 5: Python If ... Else
a = 33
b = 33
if b > a:
print("b is greater than a")
elif a == b:
print("a and b are equal")