Page 107 - Code Craft Computer-7
P. 107
Program 2: To demonstrate the if statement
On running the above program, we get the following output:
The if...else Statement
The if...else statement checks for a condition. If the condition evaluates to True , the indented block
following the if statement is executed, otherwise the indented block after the else statement is
executed. The syntax of the if.... else statement is given below:
Syntax:
if (Test Expression) :
Indented block
else:
Indented block Test Expression
Program 3: To compare two numbers and print the result
False
True
Body of if Body of else
Statement just below if
107

