Page 137 - Plus_V2.2_C7_Flipbook
P. 137

On running the above program, we get the following output:                          Factopedia
















                                                                                                Python does not
                                                                                                 require braces
                                                                                                  in conditional
                                                                                                statements which
                                                                                                makes the code
                            Let’s BaCk-uP                                                            simple.

                        The if statement is the simplest conditional statement.

                        In  the if…else statement,  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.
                        Python allows the nested if statement.
                        The if…elif…else ladder helps us to test multiple conditions and
                      follows a top-down approach.

                                                                                                   Indentation
                                                                                                defines the body
                                                                                                of the conditional
                                                                                             statements in Python.




















                                                                                                Python considers
                                                                                                a Tab equals to 8
                                                                                             spaces in indentation.





                                                                                    Conditional Statements in Python  135
   132   133   134   135   136   137   138   139   140   141   142