If – block:
- “if” is a keyword.
- “if” block is used to execute a block only if the condition is valid.
- We can place the condition directly or with parenthesis
Syntax:
if condition:
.....
logic
.....
or
if(condition):
.....
logic
.....
Flow Chart:
Simple code snippet to understand if block:
a=10
b=20
if a<b:
print("True")
Analyze code:
a=5
b=3
c=2
if a>b or a==c:
print("True")
Output it:
if True:
print("a")
print("b")
if False:
print("c")
print("d")
if False:
print("e")
print("f")