Page 32 - Modular v1.1 Pyhton
P. 32

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






















                  On running the above program, you will get the following output:





























                      NESTED IF STATEMENT

                  Python allows the  nested if statement. This

                  means the  if indented block inside  another
                  if…else indented block. The second nested if                            False
                                                                        Test Expression 1          Statement 3
                  indented block will run only when the first if
                  condition evaluates to be true.                               True

                  Syntax:
                                                                                         False
                  if (Test Expression1):                                Test Expression 2          Statement 2

                       if (Test Expression2):
                                                                                True
                            Indented block 1
                                                                          Statement 1
                       else:
                            Indented block 2


                   30     Touchpad MODULAR (Version 1.0)
   27   28   29   30   31   32   33   34   35   36   37