Page 113 - PortGPT_V2.1_C7_Flipbook
P. 113

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

                     Output

                  Enter the marks: 60
                  Passed with C grade


                  Enter the marks: 87
                  Passed with A grade                                                            Python does not
                                                                                                 require braces in
                  Enter the marks: 30                                                         conditional statements
                  Sorry!!!, You failed the exam.                                              which makes the code
                                                                                                      simple.
                  Enter the marks: 79
                  Passed with B grade










                           Let’s Back-uP


                       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,              Indentation
                      otherwise  the indented  block  after the else statement  is               defines the body
                      executed.                                                                 of the conditional
                        Python allows the nested if statement.                                 statements in Python

                        The if…elif…else ladder helps us to test multiple conditions and
                      follows a top-down approach.













                                                                                               Python's name was
                                                                                              inspired by the British
                                                                                              comedy group Monty

                                                                                                     Python.






                                                                                    Conditional Statements in Python  111
   108   109   110   111   112   113   114   115   116   117   118