Page 113 - IPP-12-2024
P. 113
28. Given the following dictionaries:
dict_exam={"Exam":"AISSCE", "Year":2023}
dict_result={"Total":500, "Pass_Marks":165}
Give the statement to merge the contents of both dictionaries.
Ans. dict_exam.update(dict_result)
29. Name the function used to display first 5 and last 5 rows from a Series or Dataframe.
Ans. head() and tail() functions.
30. Write a command to store data of dataframe mdf into a CSV file Mydata.csv, with separate character as
"@".
Ans. mdf.to_csv("Mydata.csv", sep="@")
31. What is the importance of Data Visualization? Name the various types of charts supported by Pandas.
Ans. Data Visualization is the graphical or visual representation of information and data using visual
elements like charts, graphs, maps, etc. They are often used to ease understanding of large quantities of
data and the relationships between parts of the data. Charts can usually be read more quickly than raw
data. The various types of charts supported by Pandas are line, bar, histograms, pie, box, etc.
32. What are Subplots in Matplotlib library?
Ans. Subplots are grids of plots within a single figure. Subplots can be plotted using subplots() function from
matplotlib.pyplot module.
33. Name the pyplot functions for the following work (Assume plt as the alias name for pyplot).
(a) To display gridlines in the graph ________________ .
(b) To display the legend for the chart ________________ .
(c) To display the chart ________________ .
(d) To display the heading for the graph ________________ .
(e) To display the heading for the x-axis ________________ .
(f) To remove the gridlines from the chart ________________ .
Ans. (a) plt.grid(True)
(b) plt.legend()
(c) plt.show()
(d) plt.title()
(e) plt.xlabel()
(f) plt.grid(False)
34. What is the purpose of plot() function?
Ans. plot() is a versatile command and takes an arbitrary number of arguments to plot a chart in Matplotlib
library. For example, plot (x, y) to plot x versus y.
35. List the methods used with pyplot.
Ans. Various methods used with pyplot object are:
• plot()
• show()
• title()
• xlabel()
• ylabel()
• explode()
• bar()
• hist()
• scatter()
• box plot()
36. Which function is used to draw a Histogram?
Ans. hist()
Appendices A.23