Page 75 - TP_Prime_V2.2_Class7
P. 75
evaluates to True. Otherwise, the control of execution is passed to the next statement
after the if block.
The syntax of the if statement is: Start
If condition False
Prime (Ver. 2.2)-VII Syntax Statements in if MORE ON PYTHON
True
if (condition):
block execute
Indented statement block
# if block ends here
Stop
72 There is a colon after the if condition. These are mandatory in Python. If the colon is not 73
used or indentation is not given, the interpreter will show an error.
Let us take an example:
Using if Statement
Fun Python does not require Soft Hint
Fact! braces in conditional To Indent the line: Press CTRL+]
statements which makes
the code simple. To Unindent the line: Press CTRL+[
The if...else Statement
It is to be noted that in the previous example, if the age was less than 18, there was no
statement for the interpreter to execute. An if…else statement provides a set of two
paths, one if the condition is True and the other if the condition is False.

