Page 90 - 2619_PlusGPT V2.1_C-8
P. 90

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    Test Expression
                  statement is executed, otherwise the indented block after
                  the  else  statement  is  executed.  The syntax  of the  if…else        True                 False
                  statement is given below:
                  Syntax:                                                           Body of if           Body of else

                  if (Test Expression):

                      Indented block
                                                                               Statement just below if...else
                  else:
                      Indented block


                   Program 3: To compare two numbers and print the result.


















                  88    Premium Edition-VIII
   85   86   87   88   89   90   91   92   93   94   95