Plotting with pyplot Assignments Class-12 IP

Plotting with pyplot Assignments Class-12 is one of the topic of CBSE curriculum, subject – Informatics Practices code 065. In this article you will get the assignments for the same.

Objective type questions (Plotting with pyplot Assignments Class-12)

MCQs, Fill in the blanks and True/False

Q – 1 A _________ refers to the graphical representation of data and information using charts or diagrams or maps.

–> Data Visualization

Q – 2 Data visualization helps to

a) Understand data easily

b) Take a decisions

c) Improve the past performance

d) All of these

Q – 3 The ______ module allows you to represent data visually in various forms.

–> pyplot

Q – 4 The ________ library provides the interface and functionality for plotting the graphs.

–> matplotlib

Q – 5 Which of the following offers many different names collections of methods?

a) PyPlot

b) matplotlib

c) matlab

d) graphs

Q -6 Which of the following correct statement to import pyplot module?

a) import matplotlib.pyplot

b) import MatPlotLib.PyPlot

c) import PyPlot as pl

d) import pyplot.plot

Q – 7 A __________ chart displays information as a markers connected by a straight lines.

–> Line

Q – 8 A bar chart is also known as column chart. (True/False)

Q – 9 The entire is covered by the graph is known as __________

–> Figure or Chart Area

Q – 10 Which is a common method used to plot data on the chart?

a) plot()

b) show()

c) legend()

d) title()

Q – 11 Which of the following is/are correct statement for plot method?

a) pl.plot(x,y,color,others)

b) pl.plot(x,y)

c) pl.plot(x,y,color)

d) all of these

Q – 12 What are the mandatory parameters to plot data on chart for plot() method?

a) x and y

b) color

c) others

d) None of these

Q – 13 To give a title to x-axis, which of the following method is useful?

a) pl.xtitle(“title”)

b) pl.xlabel(“title”)

c) pl.xheader(“title”)

d) pl.xlabel.show(“title”)

Q – 14 The pl.show() method must be used to display the chart in the end of the chart specification. (True/False)

Q – 15 The _________ method is used to create a line chart.

a) pl.pie()

b) pl.col()

c) pl.plot()

d) pl.line()

Q – 16 To create a horizontal bar chart, bar() function is used. (True/False)

Q – 17 To change the width of bars in bar chart, which of the following argument with a float value is used?

a) thick

b) thickness

c) width

d) barwidth

Q – 18 You can set different width for different bars in bar chart. (True/False)

Q – 19 To apply color you can only specify the color names. (True/False)

Q – 20 Which method is used to display or show the legends?

a) pl.show()

b) pl.display()

c) pl.legend()

d) pl.values()

The following section contains short answer questions for Plotting with pyplot Assignments Class-12.

Descriptive questions (2/3 marks)

Q – 1 What do you mean by data visualization technique?

The data visualization technique refers to the graphical or pictorial or visual representation of data. This can be achieved by charts, graphs, diagrams, or maps.

Q – 2 How data visualization can help in decision making?

Mostly data visualization technique provides data in form of charts or graphs. These charts majorly used in producing various reports like trends, outliers, and other diagrams. By observing these all user can understand the data easily and he/she can take his decision.

Q – 3 Name the library and interface used to plot a chart in python.

Library – matplotlib

interface – pyplot

Q – 4 What are the ways of importing matplotlib?

You can import matplotlib in following two ways:

  1. Using alias name: import matplotlib.pyplot as pp
  2. Without alias name: import matplotlib.pyplot

Q -5 What are the basic elements/components of the chart?

The chart has following elements/components:

  1. Chart area or figure
  2. Axis
  3. Artist
  4. Titles
  5. Legends

Q -6 Write steps to plot your data on a graph.

  1. import module i.e import matplolib.pyplot as pp
  2. Choose the desired chart type to plot data. For ex. Line chart
  3. Use proper titles for axis
  4. Add data points
  5. Add more properties to the graph like color, size etc.

Q – 7 What types of graphs can be plotted using matplotlib?

The matplotlib provides following types of charts:

  1. Line chart
  2. Bar chart
  3. Horizontal bar chart
  4. Histogram
  5. Scatter chart
  6. Boxplot
  7. Pie Chart

Q – 8 Write code to do the following:

[1] Plot the following data on line chart:

Runs in Overs1020
MI110224
RCB85210
import matplotlib.pyplot as mpp
overs = [10,20]
mi = [110,224]
mpp.plot(overs,mi,'blue')
rcb=[109,210]
mpp.plot(overs,rcb,'red')
mpp.xlabel('Runs')
mpp.ylabel('Overs')
mpp.title('Match Summary')
mpp.show()

[2] Write code to plot a line chart to depict the run rate of T20 match from given data:

OversRuns
545
1079
15145
20234
import matplotlib as pp
overs = [5,10,15,20]
runs = [54,79,145,234]
pp.plot(overs,runs)
pp.xlabel('Overs')
pp.ylabel('Runs')
pp.show()

Q – 9 How to change the thickness of line, line style, line color, and marker properties of a chart?

To change the thickness of line, use the linewidth parameter inside matplotlib.pyplot.plot() function with a numeric value. For ex.: pp.plot(x,y,linewidth=2)

To change the line style, use linestyle or ls parameter. This linestyle can be one of the following:

  1. solid
  2. dashed
  3. dashdot
  4. dotted

Ex. pp.plot(x,y,linestyle=’dashed’)

To change the color use color shortcode like r for red, g for green and so on. You can also use the complete colornames or hexadecimal color codes like #000800 in RGB values. Click here to know more about line colors.

To change the markers user marker properties as following:

[1] markertype: It can be a symbol such as . (dot), ‘D’ for diamond etc. Click here for more about marker types.

Ex.: pp.plot(x,y,marker=’D’)

[2] markersize: It can be a numeric value.

Ex. pp.plot(x,y,marker=’D’,markersize=4)

[3] markeredgecolor: It can be a color shortcode or color name or color code.

Ex. pp.plot(x,y,marker=’D’,markeredgecolor=’blue’)

Q – 10 Plot following data on bar graph:

English: 56,78,90,34

Science: 65,77,54,32

Maths: 45,67,43,41

import matplotlib.pyplot as pp
eng = [56,78,90,34]
sci = [65,77,54,32]
maths =[45,67,43,41]
pp.bar(eng,sci,maths)
pp.xlabel('Marks')
pp.ylabel('Subjects')
pp.show()

Click here to read notes on Data Visualization using pyplot.

Read this also: Informatics Practices

Comment Your Views

%d bloggers like this: