입력의 제곱근을 계산하려면 Python Numpy에서 scimath.sqrt() 메서드를 사용합니다. 이 메서드는 x의 제곱근을 반환합니다. x가 스칼라이면 out이고 그렇지 않으면 배열이 반환됩니다. 매개변수 x는 입력 값입니다. 음수 입력 요소의 경우 복소수 값이 반환됩니다.
단계
먼저 필요한 라이브러리를 가져옵니다 -
import numpy as np
array() 메서드를 사용하여 numpy 배열 만들기 -
arr = np.array([1, -4, -9, 16, -25, 36])
배열 표시 -
print("Our Array...\n",arr) 치수 확인 -
print("\nDimensions of our Array...\n",arr.ndim)
데이터 유형 가져오기 -
print("\nDatatype of our Array object...\n",arr.dtype) 모양 가져오기 -
print("\nShape of our Array object...\n",arr.shape)
입력의 제곱근을 계산하려면 Python Numpy에서 scimath.sqrt() 메서드를 사용합니다. 이 메서드는 x의 제곱근을 반환합니다. x가 스칼라이면 out이고, 그렇지 않으면 배열이 반환됩니다. −
print("\nResult...\n",np.emath.sqrt(arr)) 예시
import numpy as np
# Creating a numpy array using the array() method
arr = np.array([1, -4, -9, 16, -25, 36])
# Display the array
print("Our Array...\n",arr)
# Check the Dimensions
print("\nDimensions of our Array...\n",arr.ndim)
# Get the Datatype
print("\nDatatype of our Array object...\n",arr.dtype)
# Get the Shape
print("\nShape of our Array object...\n",arr.shape)
# To compute the square root of input, use the scimath.sqrt() method in Python Numpy
print("\nResult...\n",np.emath.sqrt(arr)) 출력
Our Array... [ 1 -4 -9 16 -25 36] Dimensions of our Array... 1 Datatype of our Array object... int64 Shape of our Array object... (6,) Result... [1.+0.j 0.+2.j 0.+3.j 4.+0.j 0.+5.j 6.+0.j]