Page 299 - AI Ver 1.0 Class 9
P. 299

Output:
            Enter Length : 5

            Enter Breadth : 10

            Area is : 50
            Perimeter is : 100




                            Task                                                                Experiential Learning




                 Type "import this" in your Python IDLE and you will find a poem written by Tim Peters, a major contributor
                 to the Python community.

                 _______________________________________________________________________________________________________




                            Task                                                                  Subject Enrichment



                 Input a radius of a circle. Calculate the area and perimeter of circle.

                 _______________________________________________________________________________________________________
                 _______________________________________________________________________________________________________
                 _______________________________________________________________________________________________________
                 _______________________________________________________________________________________________________

                 _______________________________________________________________________________________________________
                 _______________________________________________________________________________________________________





                    Selection Statements


            In Python,
               • Selection flow of control is achieved through conditional statements.
               • In  the  conditional/selection  statements,  flow  of  control  is  changed  based  on  a  condition.  We  specify  the
              condition in the program which evaluates to either True or False.
               • If condition is True then the block of statement written for True will be executed and in case the condition is
              False then the block of statements for False will be executed.
               • Conditional statements  are also called as branching  statements  as a program decides which statement to
              execute based on the result of the evaluated condition.
               • A block is identified by using an indentation (minimum 1 space). Ensure that all statements in one block are
              indented at the same level.

               • Python mainly provides three types of conditional statements—if, if…else and if…elif…else statements.
              Let us learn about them in detail.



                                                                                Introduction to Python  297
   294   295   296   297   298   299   300   301   302   303   304