Page 33 - Modular v1.1 Pyhton
P. 33

else:

                      Indented block 3

                 Program 3: 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 above program, you will get the following output:




























                     IF…ELIF…ELSE LADDER


                 The if…elif…else ladder is another type of if statement. It helps us to test multiple conditions
                 and follows a top-down approach. In this, as soon as the condition of the if evaluates to be true,
                 the indented block associated with that ‘if’ is executed, and the rest of the ladder is avoided.
                 If none of the conditions evaluates to true, then the final else statement gets executed.



                                                                               Conditional Statements in Python   31
   28   29   30   31   32   33   34   35   36   37   38