xxxxxxxxxx
if age >= 18:
print("You can vote!")
# You can write in single line also
if age >= 18: print("You can vote!")
xxxxxxxxxx
#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')
xxxxxxxxxx
answer = input(":")
if answer == "lol":
print("haha")
else:
print("not haha")
exit()
please note that the exit() command is optional and is not necessary.
xxxxxxxxxx
user_info = input("How may I help you?: ")
if user_info == "on":
print("Light is Turned Om")
elif user_info == "off":
print("Light is turned Off")
elif user_info == "status":
input("All are Good.What do you need?: ")
print("I don't have it")
else:
print("Shutdown processing are being Ready")
#copy the code to your py script to have the results!!!
xxxxxxxxxx
can_run = True
can_run2 = False
if can_run:
print("i can run the code because can_run is true")
elif can_run2:
print("i can run the code if can_run2 is true")
else:
print("no other bool found true")
#result should be (i can run the code because can_run is true
xxxxxxxxxx
// python if condition
a = 10
b = 20
if a > b:
print("a is greater than b")
elif a = b:
print("a is equal to b")
else:
print("a is less than b")