if and statement 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: python if and
if foo == 'abc' and bar == 'bac' or zoo == '123':
# do something
Example 3: if statement python
a = 11
b = 46
if a < b:
print('a is less than b')
else:
print('a is greater than b')
Example 4: if statement in python
answer = input(":")
if answer == "lol":
print("haha")
else:
print("not haha")
exit()
please note that the exit() command is optional and is not necessary.
Example 5: if statement python
if (condition):
result
else:
result
Example 6: 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!')