복잡한 인수의 실수 부분을 반환하려면 Python에서 numpy.real() 메서드를 사용합니다. 이 메서드는 복잡한 인수의 실제 구성 요소를 반환합니다. val이 실수이면 val 유형이 출력에 사용됩니다. val에 복잡한 요소가 있는 경우 반환되는 유형은 float입니다. 첫 번째 매개변수 val은 입력 배열입니다.
단계
먼저 필요한 라이브러리를 가져옵니다 -
import numpy as np
array() 메서드를 사용하여 배열 생성 -
arr = np.array([56.+0.j , 27.+0.j , 68.+0.j , 23.+0.j])
배열 표시 -
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...\n",arr.shape)
복잡한 인수의 실수 부분을 반환하려면 Python에서 numpy.real() 메서드를 사용합니다. 이 메서드는 복잡한 인수의 실제 구성 요소를 반환합니다. val이 실수이면 val 유형이 출력에 사용됩니다. val에 복잡한 요소가 있는 경우 반환되는 유형은 float입니다. 첫 번째 매개변수인 val은 입력 배열입니다. -
print("\nResult (Real part)...\n",np.real(arr)) 예시
import numpy as np
# Create an array using the array() method
arr = np.array([56.+0.j , 27.+0.j , 68.+0.j , 23.+0.j])
# 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...\n",arr.shape)
# To return the real part of the complex argument, use the numpy.real() method in Python
print("\nResult (Real part)...\n",np.real(arr))의 .real() 메서드 출력
Our Array... [56.+0.j 27.+0.j 68.+0.j 23.+0.j] Dimensions of our Array... 1 Datatype of our Array object... complex128 Shape of our Array... (4,) Result (Real part)... [56. 27. 68. 23.]