Skip to content
Question

Q.Consider the following graph. Write the Python code to plot it. Also add the Title, label for X and Y axis. Use the following data for plotting the graph smarks = [10, 40, 30, 60, 55] sname = ["Sahil", "Deepak", "Anil", "Ravi", "Riti"] [Figure: line graph titled 'Marks secured by students in Term-1', X-axis label 'Student Name' (Sahil, Deepak, Anil, Ravi, Riti), Y-axis label 'Marks Scored'; all plotting data is given above in text]

(OR)
Write Python code to draw the following bar graph representing the total sales 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"] [Figure: bar graph titled 'Sales each quarter', X-axis label 'Quarter' (QTR1-QTR4), Y-axis label 'Sales'; all plotting data is given above in text]
CBSECBSE Class XII Board 2023Subjective· 5mImportance★★★★★
🔒 Locked · start free trial →

You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.

Start your 14-day free trial to unlock the full solution →

Part (a): draw a line graph of student marks with plt.plot(sname, smarks) plus title and axis labels.

Part (b): draw a bar graph of quarterly sales with plt.bar(qtr, sales) plus title and axis labels.

Part (a)

A line graph joins the data points with a line and suits an ordered set of readings. Put the student names on the X-axis and their marks on the Y-axis.

import matplotlib.pyplot as plt

smarks = [10, 40, 30, 60, 55]
sname  = ["Sahil", "Deepak", "Anil", "Ravi", "Riti"]

plt.plot(sname, smarks)
plt.title("Marks secured by students in Term-1")
plt.xlabel("Student Name")
plt.ylabel("Marks Scored")
plt.show()
``` …

Unlock everything free for 14 days

  • Full step-by-step solutions
  • Concept-first explanations
  • Methods, shortcuts & mistakes
  • PYQ mapping + timed mock tests

Full access for 14 days. No credit card required.