Python If statement is used to perform some task based on a specified condition. Python if, if-else statements. Applying conditions using if-else statements.
a = 6
if a < 10:
print("hello")
print(a)
if a < 10:
print('a is less than 10.')
else:
print('a is greater than 10.')
Output:
hello
6
a is less than 10.
x = 10
y = 30
print("X") if x > y else print("Y")
if a < 10:
if a == 5:
print("Welcome")
else:
print("Go home")