0% found this document useful (0 votes)
56 views7 pages

Practical 1

The document is a Jupyter Notebook titled 'Practical 1 - 2D plots Using Python' created by Advait Trimbake, detailing various Python plotting exercises. It includes instructions and code for generating bar graphs, horizontal bar graphs, pie charts, histograms, scatter plots, and 2D function plots using libraries like Matplotlib and NumPy. The notebook showcases practical applications of data visualization techniques in Python programming.

Uploaded by

Advait Trimbake
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)
56 views7 pages

Practical 1

The document is a Jupyter Notebook titled 'Practical 1 - 2D plots Using Python' created by Advait Trimbake, detailing various Python plotting exercises. It includes instructions and code for generating bar graphs, horizontal bar graphs, pie charts, histograms, scatter plots, and 2D function plots using libraries like Matplotlib and NumPy. The notebook showcases practical applications of data visualization techniques in Python programming.

Uploaded by

Advait Trimbake
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

9/10/81, 2:35 AM Practical 1 - Jupyter Notebook

1 Practical 1 (2D plots Using Python)


2 Name:- Advait Trimbake
3 RollNo.:- 253332131
4 Div:- B
5 Date:-21/07/2025

In [9]: 1 #[Link] python draw a bar garph to represent the data below.
2 from [Link] import *
3 x=['maths','Sci','eng','marathi','hindi']
4 y=[80,69,72,58,90]
5 bar(x,y,color='g')
6 xlabel('subject')
7 ylabel('marks')
8 title('Bar Graph')
9 show()

localhost:8888/notebooks/Practical [Link] 1/7


9/10/81, 2:35 AM Practical 1 - Jupyter Notebook

In [8]: 1 #[Link] python draw a Horizontal bar garph to represent the data belo
2 from [Link] import *
3 x=['maths','Sci','eng','marathi','hindi']
4 y=[80,69,72,58,90]
5 barh(x,y,color=['g','r','b','y','k'])
6 xlabel('subject')
7 ylabel('marks')
8 title('Horizontal Bar Graph')
9 show()

In [12]: 1 #[Link] python draw a pie graph for the data given in Q1.
2 x=['maths','Sci','eng','marathi','hindi']
3 y=[80,69,72,90,70]
4 pie(y,labels=x)
5 xlabel('Subjects')
6 ylabel('Marks')
7 title('Pie Chart')
8 legend()
9 show()

localhost:8888/notebooks/Practical [Link] 2/7


9/10/81, 2:35 AM Practical 1 - Jupyter Notebook

In [15]: 1 #[Link] python draw the histogram graph for the following data with 5
2 x=[21,22,23,4,5,6,77,8,9,10,31,32,33,34,35,36,37,18,49,50,100]
3 num_bins=5
4 hist(x,num_bins,facecolor='blue' ,alpha=0.5)
5 show()

In [24]: 1 #[Link] python draw the Scatter plot for the data given in Q4.
2 from numpy import *
3 y=[21,22,23,4,5,6,77,8,9,10,31,32,33,34,35,36,37,18,49,50,100]
4 x=[Link](1,100,21)
5 scatter(x,y,color="black",marker='p')
6 title('Scatter Graph')
7 xlabel('x axis')
8 ylabel('y axis')
9 show()

localhost:8888/notebooks/Practical [Link] 3/7


9/10/81, 2:35 AM Practical 1 - Jupyter Notebook

In [27]: 1 #[Link] a python program to plot 2D garaph of the following functions


2 # i.
3 from math import *
4 import numpy as np
5 x=[Link](1,10)
6 y=[Link](x)
7 plot(x,y)
8 show()

In [28]: 1 #ii.
2 x=[Link](-2*pi,2*pi)
3 y=[Link](x)
4 plot(x,y)
5 show()

localhost:8888/notebooks/Practical [Link] 4/7


9/10/81, 2:35 AM Practical 1 - Jupyter Notebook

In [32]: 1 #iii.
2 x=[Link](-7,2)
3 y=[Link](x)
4 plot(x,y)
5 show()

In [33]: 1 #iv.
2 x=[Link](-1,1)
3 y=[Link](x)
4 plot(x,y)
5 show()

localhost:8888/notebooks/Practical [Link] 5/7


9/10/81, 2:35 AM Practical 1 - Jupyter Notebook

In [44]: 1 #Q7.
2 #[Link] a python program to plot 2D Graph of following function f(x^2)
3 def f(x):
4 return(x**2)
5 def g(x):
6 return(x**3)
7 x=[Link](-1,1,50)
8 plot(x,f(x),'y',label='X^2')
9 plot(x,g(x),'k',label='X^3')
10 legend()
11 show()

In [50]: 1 #[Link] a python program to plot 2D Graph of the function f(x^4) in [0


2 # circle markers.
3 def f(x):
4 return(x**4)
5 x=[Link](0,5,8)
6 plot(x,f(x),'r',linestyle='--',marker='v',mfc='g',markersize=8)
7 show()

localhost:8888/notebooks/Practical [Link] 6/7


9/10/81, 2:35 AM Practical 1 - Jupyter Notebook

In [54]: 1 #[Link] a python program to generate plot of function f(x^2) in the i


2 def f(x):
3 return(x**2)
4 x=[Link](-5,5)
5 plot(x,f(x),'r',label='X^2')
6 figure(figsize=(6,6))
7 show()

<Figure size 432x432 with 0 Axes>

localhost:8888/notebooks/Practical [Link] 7/7

You might also like