>>> x = int(input("Please enter an integer: "))
Please enter an integer: 42
>>> if x < 0:
... x = 0
... print('Negative changed to zero')
... elif x == 0:
... print('Zero')
... elif x == 1:
... print('Single')
... else:
... print('More')
...
More
#best example of elif loop
a = 33
b = 33
if b > a:
print("b is greater than a")
elif a == b:
print("a and b are equal")
var_one = input("Give me a number: ")
var_one = int(var_one)
var_two = input("Give me another number: ")
var_two = int(var_two)
if var_one > var_two:
print(f"First number, {var_one} is bigger")
elif var_one < var_two:
print(f"Second number, {var_two} is bigger")
else:
print(f"Both numbers are the same : {var_one}")
boolean1 = (1 != 1)
boolean2 = (2 + 2 == 5)
boolean3 = (1 == 1)
if (boolean1):
print("Boolean one is true")
elif (boolean2):
print("Boolean two is true")
else:
print("Boolean three may, or may not be true")
x = 20
if x == 20:
print("x = 20")
elif x == 30:
print ("x = 30")
else:
print("x is not 20 or 30")