Page 326 - AI Ver 1.0 Class 9
P. 326

12   What is the use of the + operator with lists?
          Ans.  The + operator is used to concatenate the list with another list.

           13.  What do you mean by traversing a list?
          Ans.  Traversing a list means to visit each element and process it as required by a program.

           14.  What is the use of the pop( ) function?
          Ans.  The pop( ) function removes an element from the list based on the index number specified in the function and returns
              the deleted value.

        B.  Long answer type questions:

            1.  What is sequential flow? Explain with an example.
          Ans.  In  sequential  flow,  the  statements  are  placed  one  after  the  other  and  the  flow  of  execution  occurs  starting  from
              line1, line2 and so on with a top to down approach. It is the default type followed in any programming language. For
              example, Steps for calculating percentage of any student

              Input marks of English, Hindi and Math
              Total the marks
              Calculate the percentage
              Display the percentage

            2.  Explain the important symbols of flowchart.
          Ans.  Oval                 Used to start and end a flowchart.

               Parallelogram         Used for input and output operation.
               Rectangle             Used for assignment, mathematical operations, processing
               Diamond               Used for decision making in case of branching or looping.

               Arrow                 Used for to show the direction of flow of information.
            3.  Explain the use of print( ) function with all its parameters.

          Ans.  The print() function is used to print an output on the screen. It converts the expressions into a string before writing to
              the screen. Syntax to use the print( ) function is:
                  print(object(s), sep = separator, end = end)
               Where,

              •  object can be one or more separated by comma and it can be a variable, literal, expression. An object will be
                converted to string before printed.
              •  sep is used as a separator if there are more than one objects.
              •  end specifies what to print at the end. Default is newline ‘\n’.

            4.  Give two different ways of writing statements in Python.
          Ans.  •   Simple statements: By default, the end of a statement is done by pressing an Enter key. Each statement is
                written on a new line.

                 a=5 is a simple statement where variable-a is created with value 5.
                 c=a + b





                  324   Touchpad Artificial Intelligence-IX
   321   322   323   324   325   326   327   328   329   330   331