Tanishq Worksheet Python
Tanishq Worksheet Python
Q. (a) Write a python program to generate a simple bar graph using matplotlib. The
graph should be properly labelled.
(b)Write a python program to generate Pie-chart using matplotlib. The graph should be
properly labelled.
Aim/Overview of the practical: The aim of this practical is to under stand the basic data
visualization using bar chart.This writing helps you get comfortable with python code for
graphs.
1. Task to be done:
• Import the matplotlib library.
• Then , define the data.
• After defining the data, we have to create the bar graph and labelling the x and y axis.
• Now the last step we have to do is to add title to the graph and display the graph.
plt.show()
3. Result/Output/Writing Summary:
Aim/Overview of the practical: The aim of this practical is to under stand the basic data
visualization using pie chart. This writing helps you get comfortable with python code for
graphs.
3. Task to be done:
• Import the matplotlib library.
• Then , define the data.
• After defining the data, Create the pie chart .
• Now the last step we have to do is to add a title using plt.title().
• Display the pie chart.
import numpy as np
# Adding legend