Sine and Cosine Values plot using Matplotlib

import numpy as npimport matplotlib.pyplot as pltx=np.linspace(0,1)data1 = np.sin(x)data2 = np.cos(x)fig, ax1 = plt.subplots()color = ‘tab:red’ax1.set_xlabel(‘x’)ax1.set_ylabel(‘sine’, color=color)ax1.plot(x, data1, color=color)ax1.tick_params(axis=’y’, labelcolor=color)ax2 = ax1.twinx()color = ‘tab:green’ax2.set_ylabel(‘cosine’, color=color)ax2.plot(x, data2, color=color)ax2.tick_params(axis=’y’, labelcolor=color)plt.show() #Simple Implementation#———————————————————————import numpy as npimport matplotlib.pyplot as pltx = np.linspace(-np.pi, np.pi, 256,

Operations on Matrices

import numpy as npA = np.array([[4,1,7],[2,1,8],[3 ,7,1]])B = np.array([[6,1,1],[2,1,5],[2,3,1]])C=A.dot(B)print(“Values of First 2D Matrixn”,A)print(“Values of Second 2D Matrixn”,B)print(“———————————————“)print(“Multiplication of Matricesn”,C)print(“n”)Ainv=np.linalg.inv(A)Binv=np.linalg.inv(B)print(“Inverse of First Matrixn”,Ainv)print(“Inverse of Second Matrixn”,Binv)print(“n”)AI=Ainv.dot(A)BI=Binv.dot(B)print(“Multiplication of First Matrix and their Inversen”,AI)print(“Multiplication of Second Matrix and their Inversen”,BI)AD=np.linalg.det(A)BD=np.linalg.det(B)print(“n”)print(“Determinant of First Matricx:”,AD)print(“Determinant

Datatypes in Numpy

import numpy as np x = np.array([101, 202])   print(x.dtype)         x = np.array([11.75, 21.75])  print(x.dtype)             x = np.array([1, 2], dtype=np.int64)  print(x.dtype)                     x = np.array([1, 2], dtype=np.complex128)  print(x.dtype)  Source link

Mathematical operators on Numpy Array and List

import numpy as np a = np.array([1, 2, 3]) print(type(a))            print(‘Numpy Array:n’,a)print(‘Addition of Numpy Arrays with constant:n’,a+13)print(‘Addition of Numpy Arrays:n’,a+a)print(‘Multiplication of Numpy Arrays with constant:n’,a*3)print(‘Multiplication of Numpy Arrays with another:n’,a*a)print(‘Divison of Numpy Arrays with constant:n’, a/3)print(‘Divison of Numpy Arrays with

Statistical and Extrema operations on Numpy Array

import numpy as npx = np.array([11, 13, 121, 181, 99, 100])print(‘Numpy Array Elements’,x)print (‘Minimum Value in array’,x.min())print (‘Maximum Value in array’,x.max())print (‘Index of Minimum Value’,x.argmin())print (‘Index of Maximum Value’,x.argmax())print (‘Mean of Array Values’,x.mean())print (‘Median of Array Values’,np.median(x))print (‘Standard deviation of