if else statement in python code example
Example 1: python if statement
usrinput = input(">> ")
if usrinput == "Hello":
print("Hi")
elif usrinput == "Bye":
print("Bye")
else:
print("Okay...?")
Example 2: 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 3: or statement python
if x==1 or y==1:
print(x,y)
Example 4: if statement python
x=1; y=0; z=0;
if x==1 or y==0:
if z=0 and x=1:
print('Useless conditions satisfed!')
Example 5: else if python
if expression1:
statement(s)
elif expression2:
statement(s)
elif expression3:
statement(s)
else:
statement(s)
Example 6: if statement python
number = 5
if number == 5:
print("number equals 5")
else:
print("number does not equal 5")