Page 131 - TechPluse_C8_Flipbook
P. 131

The syntax of nested if statement is shown below:

                 if (Test Expression1):
                                                                                         False
                                                                      Test Expression 1           Statement 3
                      if (Test Expression2):
                           Indented block 1
                                                                               True
                      else:
                           Indented block 2                                             False
                                                                      Test Expression 2           Statement 2
                 else:
                      Indented block 3                                         True



                                                                         Statement 1




                 Program 5: To find out if the student is selected for the college or not based on the given
                 conditions –
                 1.  Selected if age > 18 and marks > 65.
                 2.  Not selected if age > 18 and marks < 65.

                 3.  Not selected if age < 18.




















                 On running the program given on previous page, we get the following output:


























                                                                Conditional and Looping Statements in Python         129
   126   127   128   129   130   131   132   133   134   135   136