Maths Practical 1

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

5/4/23, 3:33 AM PRACTICAL 1 - Jupyter Notebook

In [22]:

#(1)logarithmic functions
#To plot the function f()=log1o(x) on the interval[0,10]
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(0,10)
y = np.log10(x, where=x>0)
plt.plot(x,y)
plt.show()

localhost:8888/notebooks/PRACTICAL 1.ipynb# 1/10


5/4/23, 3:33 AM PRACTICAL 1 - Jupyter Notebook

In [2]:

#(2)Trignometric Functions
#To plot the function f(*)=cos(x)on the interval[0,2r]
import matplotlib.pyplot as plt
import numpy as np
x = np.arange(0,2*(np.pi),0.1)
y = np.cos(x)
plt.plot(x,y)
plt.show()

localhost:8888/notebooks/PRACTICAL 1.ipynb# 2/10


5/4/23, 3:33 AM PRACTICAL 1 - Jupyter Notebook

In [3]:

#(3)InverseTrignometricFunctions
#To plot the function f(x)=sin'(x) on the interval[-1,1]
import matplotlib.pyplot as plt
import numpy as np
x = np.arange(-1,1,0.01)
y = np.arcsin(x)
plt.plot(x,y)
plt.show()

localhost:8888/notebooks/PRACTICAL 1.ipynb# 3/10


5/4/23, 3:33 AM PRACTICAL 1 - Jupyter Notebook

In [5]:

#(4)AlgebraicFunction
#To plot the function f(x)=x² on the interval[-2,2]
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(-2,2,100)
y = x**2
fig = plt.figure(figsize=(10,5))
plt.plot(x,y)
plt.show()

localhost:8888/notebooks/PRACTICAL 1.ipynb# 4/10


5/4/23, 3:33 AM PRACTICAL 1 - Jupyter Notebook

In [7]:

#(4)ExponentialFunction
#To plot the function f(x)=e^x on the interval[-1,100]
import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(-1,2,100)
y = np.exp(x)
plt.plot(x,y)
plt.show()

localhost:8888/notebooks/PRACTICAL 1.ipynb# 5/10


5/4/23, 3:33 AM PRACTICAL 1 - Jupyter Notebook

In [10]:

#(5)Linegraphs
import matplotlib.pyplot as plt
x1 = [1,2,3]
y1 = [3,6,2]
plt.plot(x1,y1,label="line1")
x2 = [1,2,3]
y2 = [7,2,5]
plt.plot(x2,y2,label="line2")
plt.xlabel('x-axis')
plt.ylabel('y-axis')
plt.title('Twolinesonsamegraph')
plt.legend()
plt.show()

localhost:8888/notebooks/PRACTICAL 1.ipynb# 6/10


5/4/23, 3:33 AM PRACTICAL 1 - Jupyter Notebook

In [16]:

#(6)Bargraph
import matplotlib.pyplot as plt
left = [1,2,3,4,5]
height = [5,24,45,32,15]
tick_label = ['Pune','Mumbai','Nagpur','Nasik','Satara']
plt.bar(left,height,tick_label = tick_label,width = 0.8,color = ('red','green'))
plt.xlabel('cities')
plt.ylabel('NoofCovidpatients(inthousands)')
plt.title('Covid-19data')
plt.show()

localhost:8888/notebooks/PRACTICAL 1.ipynb# 7/10


5/4/23, 3:33 AM PRACTICAL 1 - Jupyter Notebook

In [19]:

#(7)Histogram
ages = [2,5,70,40,30,45,50,45,43,40,44,60,7,13,57,18,90,77,32,21,20,40,45,32,38]
range = (0,100)
bins = 5
plt.hist(ages,bins,range,color ='blue',histtype = 'bar',width=0.8)
plt.xlabel('age')
plt.ylabel('No.ofpeople')
plt.title('histogramplot')
plt.show()

localhost:8888/notebooks/PRACTICAL 1.ipynb# 8/10


5/4/23, 3:33 AM PRACTICAL 1 - Jupyter Notebook

In [20]:

#(8)pieChart
import matplotlib.pyplot as plt
left = [1,2,3,4,5]
height = [5,24,45,32,15]
tick_label = ['Pune','Mumbai','Nagpur','Nasik','Satara']
fig = plt.figure(figsize=(10,7))
plt.pie(height,labels = tick_label)
plt.show()

localhost:8888/notebooks/PRACTICAL 1.ipynb# 9/10


5/4/23, 3:33 AM PRACTICAL 1 - Jupyter Notebook

In [21]:

#(9)Scatterdiagram
import matplotlib.pyplot as plt
girls_scores = [81,90,70,89,100,80,90,100,80,34]
boys_scores = [30,29,49,48,100,48,34,45,20,30]
grades_range = [10,20,30,40,50,60,70,80,90,100]
fig = plt.figure()
ax = fig.add_axes([0,0,1,1])
ax.scatter(grades_range,girls_scores,color = 'r')
ax.scatter(grades_range,boys_scores,color = 'b')
ax.set_xlabel('GradesRange')
ax.set_ylabel('GradesScored')
ax.set_title('scatterplot')
plt.show()

In [ ]:

localhost:8888/notebooks/PRACTICAL 1.ipynb# 10/10

You might also like