Numpy Session 7 Code

Numy Session 7 Code For Video Click Fahad Hussain CS


# sin, cos, tan, sinh, cosh, tanh FUNCTIONS.....

import numpy as np  

import math  

arr = np.array([1,2,3])  

print(arr)   

result = np.sin(arr)  

print(result)  


#Numpy arccos() method

#This function is used to calculate the inverse cos of the array elements.

import numpy as np   

arr = [0, 0.3, -1]   

print (arr)   

arccos_val = np.arccosh(arr)   

print(arccos_val) 


#array: these are the array elements of which, the inverse sin values are to be calculated.

#Out: It is the shape of the output array.


#Numpy arcsin() method


import numpy as np   

import math  

arr = [0, 0.3, -1]   

print(arr)   

arcsine = np.arcsin(arr)   

print(arcsine)


#Numpy arctan() method

#This function is used to calculate the inverse tangent of the array elements.


import numpy as np   

arr = [0, 0.3, -1]   

print(arr)   

  

arctan_val = np.arctan(arr)   

print(arctan_val)   


#Numpy degrees() method

#This function is used to convert the angles from radian to degrees.


import numpy as np   

import math  

  

arr = [1,2,3]   

print(arr)   

degval = np.degrees(arr)   

print(degval)   


#Numpy deg2rad() method

#This function is used to convert the angles from degree to radian.


import numpy as np   

import math  

arr = [0,1,5]   

print(arr)   

radval = np.deg2rad(arr)   

print(radval) 



# Numpy hypot() method

# This function is used to calculate the hypotenuse for the right angled triangle.

# h = sqrt(b**2 + p**2)  


import numpy as np  

  

base = [10,2,5,50]  

per= [3,10,23,6]  

  

print("Input base array:",base)  

print("Input perpendicular array:",per)  

  

hyp = np.hypot(base,per)  

  

print("hypotenuse ",hyp)  


#Numpy rad2deg() method


import numpy as np   

import math  

  

arr = [0,1,5]   

print ("Input array : \n", arr)   

  

degval = np.rad2deg(arr)   

print ("\n Degree value : \n", degval)  


#Numpy radians() method

import numpy as np   

  

arr = [0, 30, 60, 90 ]   

print ("Input array : \n", arr)   

  

radval = np.radians(arr)   

print ("\n Radian value : \n", radval) 


#Numpy arcsinh()

import numpy as np  

import math  

  

arr = np.array([0, 4,5])  

  

print("Input Array:",arr)  

print("tanh Array:",end=" ")  

  

arcsinharr = np.arcsinh(arr)  

print(arcsinharr) 



#Numpy arctanh()

import numpy as np  

import math  

  

arr = np.array([0,0.2, 0.5, 0.3])  

  

print("Input Array:",arr)  

print("arctanh Array:",end=" ")  

  

arctanharr = np.arctanh(arr)  

print(arctanharr)  



import numpy as np

ar = 2.49

arr = [0.23, 0.9, 1.56, 1.50, 9.99, 1.1]  


print("Input array:",arr)

print("\nAfter ceil applying: ",np.ceil(arr))

print("\nAfter FLOOR applying: ",np.floor(arr))

print("\nAfter ROUND applying: ",np.round(arr))

print("\nAfter rint applying: ",np.rint(arr))



#Numpy fix()

#This function is used to round the array values to the nearest integers towards zero.


import numpy as np  

  

arr = [0.23, 0.9, 1.56, 1.50, 9.99, 1.1]   

print("Input array:",arr)  

r_arr = np.fix(arr)  

print("Output array:",r_arr)  


#Numpy trunc()

#This function returns the truncated value of the input array elements.

# The truncated value t of input value x 

# is the nearest integer which is closer to zero than x.


#The fractional part of the input number is discarded by this function


import numpy as np  

arr = [0.23, 0.9, 1.56, 1.50, 9.99, 1.1]  

  

print("Input array:",arr)  

r_arr = np.trunc(arr)  

print("Output array:",r_arr)  

  



No comments:

Post a Comment

Fell free to write your query in comment. Your Comments will be fully encouraged.