|Syntax:||if condition :
|Description:||executes statements if condition is true (or not 0)|
|Parameters:||condition||A value or an expression evaluates to a 0 or not 0|
|Related:||if .. elif .. else, while, for, condition|
The condition can be a value or an expression. An expression may contain contain comparison operators. Such as == , < , >= etc.
If the condition evaluates to true value (or a non zero value) then the statements that follow are executed once. (the statements are a block of code is where all the lines are indented by the same number of space characters)
a = 10
if a < 20:
print('a is ', a)
The Condition may be an expression containing with multiple values and brackets.
if (a+b)/4 >= 5:
print('the sum of a+b is', a+b)
The expression may be made of multiple parts separated by and and or keywords.
if (a+b> 20) and (c+d==5) :
print('the magic combination')
The condition may be a single value such as
This condition works so long as the value a is not 0