Page 128 - Informatics_Practices_Fliipbook_Class12
P. 128

4.  Consider the following list representing the number of products sold by an online store in the last five days:
              [120, 150, 200, 180, 250]
              Write a Python program to create a bar graph to compare the sales for each day using Matplotlib.

         Ans.      import matplotlib.pyplot as plt
                  sales = [120, 150, 200, 180, 250]
                  weekDays = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri']
                  plt.bar(weekDays, sales, color='skyblue')
                  plt.xlabel('Days of the Week')
                  plt.ylabel('Number of Products Sold')
                  plt.title('Sales for Each Day')
                  plt.show()





















                                             Bargraph depicting sales for each day




                                                  Assessment


        A.  Multiple Choice Questions
           1.  Which type of graph is most suited to compare the distribution of categorical data?
              a.  Line plot            b. Bar graph           c. Histogram           d. Scatter plot
           2.  What does the height of each bar in a histogram signify?
              a.  Frequency of the data
              b.  Mean of the data
              c.  Standard deviation of the data
              d.  Range of the data
           3.  Which function is used to produce several subplots in a single figure?
              a.  plt.plot()           b. plt.subplot()       c. plt.multiple()      d. plt.subplots()
           4.  Which inputs should you provide to the scatter() function to produce a scatter plot with blue markers?
              a.  plt.scatter(x,y,color='blue')
              b.  plt.scatter(x,y,marker='blue')
              c.  plt.scatter(x,y,c='blue')
              d.  plt.scatter(x,y,color='blue', marker='o')
           5.  Which of the following plots is used to depict the distribution of a single continuous variable?
              a.  Line plot            b. Bar graph           c. Scatter plot        d. Histogram



          114  Touchpad Informatics Practices-XII
   123   124   125   126   127   128   129   130   131   132   133