if or 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: or statement python
if x==1 or y==1:
print(x,y)
Example 3: python if and
if foo == 'abc' and bar == 'bac' or zoo == '123':
# do something
Example 4: if statement python
#a statement that checks if a condition is correct
#example:
x=5
if x == 5:
print("x is 5")
else:
print("x is not 5")
Example 5: 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 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!')