Page 13 - IPP-12-2024
P. 13

35.  Plot the following data using a line plot:                                              [5]

                    days=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"]
                      tickets_sold=[2000,2800,3000,2500,2300,2500,1000]
                      Change the color of the line to ‘Magenta’.
                      Set marker as ‘*’
                      Set x and y labels as days and numbers of tickets sold respectively.
                      Set the title as day-wise tickets sold.
                      Also, give a suitable Python statement to save this chart.

                Ans.  import matplotlib.pyplot as plt
                    x=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"]
                     y=[2000,2800,3000,2500,2300,2500,1000]
                     plt.plot(x,y,color="magenta",marker="*")
                     plt.title("Day wise Tickets sold ")
                     plt.xlabel("Days")
                     plt.ylabel("No of tickets sold")
                     plt.show()
                     plt.savefig('aa.jpg')
                                                               Or
                      WAP to plot a bar showing the favourite movie type of different sets of people.
                                                          Favourite types of movies
                                               6
                                               5

                                               4
                                             POPULARITY  3 2




                                               1

                                               0
                                                  Comedy  Action  romance  drama  scifi
                                                              MOVIE TYPE
                      Also, give a suitable Python statement to save this chart.

                Ans.  import matplotlib.pyplot as pp
                     movies=['comedy','action','romance','drama','scifi']
                     type=[4,5,6,1,4]
                     pp.bar(movies , type, color = 'red')
                     pp.xlabel('MOVIE TYPE')
                     pp.ylabel('POPULARITY')
                     pp.title('Favourite types of movies')
                     pp.show()
                     pp.savefig('aa.jpg')







                              For CBSE Sample Question Paper (with Solutions), scan





                                                                                         Appendices          A.35
   8   9   10   11   12   13   14   15   16   17   18