There are three types of Control Statements in python if, if_else and if_elif_else.

As long as the expression given by these control statements is not true, then it is its own statement; does not execute.

If the expression in true if statement is true then it executes its statement and if the expression is false then else statement; execute.



Syntax for if_else Statement

if expression:
  if_statement (s)
else:
  else_statement (s)


Example for if_else Statement

1.Source Code:

x = 4
y = 4

if (x <y):
     print ("x is less than y")
else:
     print ("x is greater than or equal to y")

Output:

x is greater than or equal to y

if else statement in python

Example for if_else Statement

2.Source Code:

x = 3
y = 6

if (x <y):
     print ("x is less than b")
else:
     print ("x is greater than or equal to y")

Output:

x is less than y

if else statement


check my previous post click here