xxxxxxxxxx
variable_name = input("y/n? >> ")
if variable_name == "y":
print("That's good! :) ")
# note the double equal signs. only a single equal sign will receive a Syntax error blah blah blah message.
elif variable_name == "n":
print("That's bad! :( ")
else:
print("You blow up for not following my instructions. Detention forever and get lost!")
xxxxxxxxxx
if num<5:
print('Num less than 5')
elif 5<= num <=9:
print('Num between 5 and 9')
else:
print('Num more than 9')
xxxxxxxxxx
if (condition1):
print('condition1 is True')
elif (condition2):
print('condition2 is True')
else:
print('None of the conditions are True')
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
if my_condition:
# Do some stuff
print("Hello You!")
else:
# Do some stuff
print("Hello World!")
xxxxxxxxxx
a = 11
b = 46
if a < b:
print('a is less than b')
else:
print('a is greater than b')
xxxxxxxxxx
num = int(input("Pls Enter your First Number </>: "));
if num%2==0:
if num%3==0:
print (num+100)
else :
print (num)
else:
print(num+1)
xxxxxxxxxx
#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")