Page 130 - Informatics_Practices_Fliipbook_Class12
P. 130

2.  Consider the following graph. Write the Python code to plot it. Also add the Title, and label for X and Y axis.   [2023]
              Use the following data for plotting the graph:
              smarks=[10,40,30,60,55]
              sname=["Sahil", "Deepak", "Anil", "Ravi", "Riti"]
                                               Marks Secured by students in Term-1
                                        60


                                        50

                                      Marks scored  40

                                        30


                                        20

                                        10
                                           Sahil   Deepak     Anil     Ravi     Riti
                                                          Student Name
                                                           OR
              Write python code to draw the following bar graph representing the total sale in each quarter. Add the title, Label for X-Axis,
              and Y-Axis.
              Use the following data for plotting the graph:
              sales=[450,300,500,650]
              qtr=["QTR1","QTR2","QTR3","QTR4"]
                                                       Sales each quarter
                                       600

                                       500

                                       400
                                      Sales  300


                                       200
                                       100


                                         0
                                                  QTR1     QTR2     QTR3     QTR4
                                                            Quarter

         Ans.  import matplotlib.pyplot as plt
              smarks=[10,40,30,60,55]
              sname=["Sahil", "Deepak", "Anil", "Ravi", "Riti"]
              plt.plot(sname,smarks)
              plt.xlabel("Student Name")
              plt.ylabel("Marks Scored")
              plt.title("Marks Secured by students in Term - 1")
              plt.show()





          116  Touchpad Informatics Practices-XII
   125   126   127   128   129   130   131   132   133   134   135