Practical List
Practical List
Practical List
PYTHON
Lab Record 14
Plotting –I
Aim:
Write a program to plot a range from 1 to 30 with step value 4. Use following
algebraic expression to show data: y = 5*x + 2.
Source Code:
import matplotlib.pyplot as plt
import numpy as np
x = np.arange(1,30,4)
y=5*x+2
plt.plot(x,y)
plt.show()
Output:
Conclusion:
Thus the program to plot a algebraic expression to show data: y = 5*x + 2 was
executed successfully and output was verified.
Lab Record 15
Plotting –II
Aim:
Fib={0,1,1,2,3,5,8,13,21,34}
WAP to plot the Fibonacci terms and their square roots with separate lines on
The Fibonacci series should be plotted as a cyan line with ‘o’ markers
having size as 5 and edge-color as red.
The Square- root series should be plotted as a black line with ‘+’ markers
having size as 7 and edge-color as red.
Source Code:
import matplotlib.pyplot as plt
import numpy as np
fib=[0,1,1,2,3,5,8,13,21,34]
sqfib=np.sqrt(fib)
plt.figure(figsize=(4,4))
plt.plot(range(1,11),sqfib,'k+',markersize=7, linestyle="solid",
markeredgecolor='r')
plt.show()
Output:
Conclusion:
Thus the python program to plot Fibonacci and its square root has been
executed successfully and output was verified.
Lab Record 16
Plotting –III
Aim:
To plot the given list of numbers and the square root of the numbers in a
line chart.
Source code:
import matplotlib.pyplot as p1
l1=[1,2,3,4,5,6]
l2=[1,4,9,16,25,36]
p1.xlabel("Number")
p1.ylabel("Sqroot of Numbers")
p1.plot(l1,l2)
p1.show()
Output:
Conclusion:
Thus the python program to plot the given set of numbers and its square root
has been executed successfully and output was verified.
Lab Record 17
Plotting –IV
Aim:
Plotting line graph with customized line width, style and marker size and
edgecolor.
Source Code:
import matplotlib.pyplot as p1
l1=[1,2,3,4,5,6]
l2=[2,5,8,9,6,3]
p1.xlabel("busses")
p1.ylabel("carss")
p1.plot(l1,'b',linewidth=2.5,marker="+",markersize=10,markeredgecolor="b")
p1.plot(l2,'r',linewidth=2.5,linestyle='dashed')
p1.show()
Output:
Conclusion:
Thus plotting line graph with customized line width, style and marker size and
edgecolor has been executed successfully and output was verified.
***************************************