0% found this document useful (0 votes)
2 views1 page

Practical File

The document contains Python code for creating a line chart and a scatter chart using matplotlib. It first displays a line chart for the points (2,5) to (9,10) and then a scatter plot comparing the mathematics and science marks of 10 students. The code includes necessary labels and titles for both charts.

Uploaded by

mdyusuff2124
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views1 page

Practical File

The document contains Python code for creating a line chart and a scatter chart using matplotlib. It first displays a line chart for the points (2,5) to (9,10) and then a scatter plot comparing the mathematics and science marks of 10 students. The code includes necessary labels and titles for both charts.

Uploaded by

mdyusuff2124
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

3.

Write a program to display line chart from (2,5) to (9,10):

import matplotlib.pyplot as plt

# Define data points


x = [2, 9] # X-axis points
y = [5, 10] # Y-axis points

# Create the line chart


plt.plot(x, y)

# Add labels and title


plt.xlabel("X-axis")
plt.ylabel("Y-axis")
plt.title("Line Chart")

# Display the chart


plt.show()

4.Write a program to display a scatter chart for the following points (2,5), (9,10),(8,3),(5,7),(6,18).

Write a Python program to draw a scatter plot comparing two subject marks
of Mathematics and Science. Use marks of 10 students.
Test Data:
math_marks = [88, 92, 80, 89, 100, 80, 60, 100, 80, 34]
science_marks = [35, 79, 79, 48, 100, 88, 32, 45, 20, 30]
marks_range = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
Sample Solution:
Python Code:
import matplotlib.pyplot as plt
import pandas as pd
math_marks = [88, 92, 80, 89, 100, 80, 60, 100, 80, 34]
science_marks = [35, 79, 79, 48, 100, 88, 32, 45, 20, 30]
marks_range = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
plt.scatter(marks_range, math_marks, label='Math marks', color='r')
plt.scatter(marks_range, science_marks, label='Science marks', color='g')
plt.title('Scatter Plot')
plt.xlabel('Marks Range')
plt.ylabel('Marks Scored')
plt.legend()
plt.show()

You might also like