MGOwen
0
Q:

python if else

a = 200
b = 33
if b > a:
	print("b is greater than a")

elif a == b:
	print("a and b are equal")

else:
	print("a is greater than b")

 
44

a = 33

b = 200

if b > a:
  print("b is greater than a")
 
3
# 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')
    
7
#Conditionals statements in python
#'=' conditionals statements
a = 123
b = 123

if(a==b):
  print('True')
  
#<, > conditionals statements

a = 2
b = 45

if(a<b):
  print('A is smaller than B')
  
4
usrinput = input(">> ")
if usrinput == "Hello":
  print("Hi")
elif usrinput == "Bye":
  print("Bye")
else:
  print("Okay...?")
  
10
if (condition):
   result
    
else:
   result
13
#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")
1
x=1; y=0; z=0;
if 1 in {x,y,z}:
  print('At least one variable is equal to 1')
9
answer = input(":")
if answer == "lol":
  print("haha")
else:
  print("not haha")
  exit()

please note that the exit() command is optional and is not necessary.
6

a = 33

b = 33

if b > a:

	 
	print("b is greater than a")

elif a == b:

	 
	print("a and b are equal")

 
1

New to Communities?

Join the community