Page 359 - Informatics_Practices_Fliipbook_Class12
P. 359

The else block, on the other hand, is executed when none of the preceding if or elif conditions are met.
                  It is used as a catch-all block to specify what happens when no conditions are true.

             108.  What is purpose of range() function? Give one example.
             Ans. The range() function generates an iterable sequence using the arguments start, stop and stop of range()
                  function. It is very handy and useful for the 'for' loops, which require an iterable sequence for looping.

             109.  Differentiate between break and continue statements.

             Ans. break
                  Purpose: Terminates the current loop prematurely.

                  Effect: Exits the loop completely, and the program continues with the next statement after the loop.
                  Typical use case: Used when you want to exit the loop based on a specific condition being met.
                  continue

                  Purpose: Skips the current iteration of the loop.
                    Effect: The loop continues with the next iteration, bypassing any code that follows the continue statement
                  within the current iteration.

                  Typical use case: Used when you want to skip some iterations but continue the loop for others based on a
                  condition.

             110.  What is an infinite loop? Give one example.

             Ans. An  infinite  loop  is  the  one  whose  terminating  condition  is  either  missing  or  is  not  reachable.  Thus,  the
                  body-of-the-loop keeps repeating endlessly in an infinite loop.

             111.  List one Python library that can be used for visualizing data in form of histograms, bar charts, pie charts or
                  scatter plot.

             Ans. Matplotlib
             112.  Which method of matplotlib.pyplot library can be used for plotting the point(x,y)? Also, provide the syntax of
                  the method.
             Ans. The plot() method of pyplot module can be used for plot the point(x,y). The format of the method is as
                  follows: plt.plot(x, y, format_string). The first argument represents the x-coordinate of the point,
                  the second argument represents the y-coordinate, and the following string specifies the style.

             113.  Which method of matplotlib.pyplot library can be used for rendering the plot on the screen?

             Ans. plt.show()
             114.  Determine the parameters of method plt.plot() that can be set to customize the line plot by specifying the
                  following:
                  (i)  x-coordinate or array of x-coordinates for the point(s) to be plotted.
                  (ii)   y-coordinate or array of y-coordinates for the point(s) to be plotted. It should correspond to the x-coordinates
                      and have the same length.
                  (iii)  Marker style for the point(s)
                  (iv)  Size of the marker(s).

                  (v)  Style of line connecting the point(s)
                  (vi)  Color of the marker(s) and line(s)
                  (vii)  Width of the line


                                                                                            Viva Voce Questions  345
   354   355   356   357   358   359   360   361   362   363   364