NumPy
INPUT 1:
#Access elements from 2-D arrays
import numpy as np
arr=[Link]([[1,2,3,4,5],[6,7,8,9,10]])
print("From 2-D",arr[0,1])
#Access elements from 3-D arrays
import numpy as np
arr=[Link]([[[1,2,3],[4,5,6]],[[7,8,9],[10,11,12]]])
print("From 3-D",arr[0,1,2])
OUTPUT 1:
From 2-D 2
From 3-D 6
INPUT 2:
#Slicing Array in 1-D
import numpy as np
arr=[Link]([1,2,3,4,5,6,7])
print("slicing in 1-D",arr[1:5])
#Slicing Array in 2-D
import numpy as np
arr=[Link]([[1,2,3,4,5],[6,7,8,9,10]])
print("slicing in 2-D",arr[1,1:4])
OUTPUT 2:
slicing in 1-D [2 3 4 5]
slicing in 2-D [7 8 9]
Matplotlib
INPUT 1:
#Draw line diagram between two positions
import [Link] as plt
import numpy as np
xpoints = [Link]([0,6])
ypoints = [Link]([0,250])
[Link](xpoints,ypoints)
[Link]()
OUTPUT 1:
INPUT 2:
#Draw point without line
import [Link] as plt
import numpy as np
xpoints = [Link]([1,8])
ypoints = [Link]([3,10])
[Link](xpoints,ypoints,'o')
[Link]()
OUTPUT 2:
INPUT 3:
#Draw multiple points with different arguments
import [Link] as plt
import numpy as np
ypoints = [Link]([3,8,1,10]) #Default xpoints
[Link](ypoints,marker='o',ms=20,mec='r',mfc='b')
[Link]()
OUTPUT 3:
INPUT 4:
#Draw multiple lines
import [Link] as plt
import numpy as np
y1=[Link]([3,8,1,10])
y2=[Link]([6,2,7,11])
[Link](y1)
[Link](y2)
[Link]()
OUTPUT 4:
INPUT 5:
#Draw plot with lables and title
import [Link] as plt
import numpy as np
x=[Link]([80,85,90,95,100,105,110,115,120,125])
y=[Link]([240,250,260,270,280,290,300,310,320,330])
[Link](x,y)
[Link]("Sports Watch Data")
[Link]("Average Pulse")
[Link]("Calorie Burnage")
[Link]()
OUTPUT 5: