जटिल तर्क के काल्पनिक भाग को वापस करने के लिए, numpy.imag() विधि का उपयोग करें। विधि जटिल तर्क का काल्पनिक घटक लौटाती है। यदि वैल वास्तविक है, तो आउटपुट के लिए वैल के प्रकार का उपयोग किया जाता है। यदि वैल में जटिल तत्व हैं, तो लौटा हुआ प्रकार फ्लोट है। पहला पैरामीटर, वैल इनपुट ऐरे है
कदम
सबसे पहले, आवश्यक पुस्तकालयों को आयात करें -
import numpy as np
सरणी () विधि का उपयोग करके एक सरणी बनाएं -
arr = np.array([36.+5.j , 27.+3.j , 68.+2.j , 23.+7.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) जटिल तर्क के काल्पनिक भाग को वापस करने के लिए, पायथन में numpy.imag() विधि का उपयोग करें। विधि जटिल तर्क का काल्पनिक घटक लौटाती है। यदि वैल वास्तविक है, तो आउटपुट के लिए वैल के प्रकार का उपयोग किया जाता है। यदि वैल में जटिल तत्व हैं, तो लौटा हुआ प्रकार फ्लोट है। पहला पैरामीटर, वैल इनपुट ऐरे है -
print("\nResult (Imaginary part)...\n",np.imag(arr)) उदाहरण
import numpy as np
# Create an array using the array() method
arr = np.array([36.+5.j , 27.+3.j , 68.+2.j , 23.+7.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 imaginary part of the complex argument, use the numpy.imag() method in Python
print("\nResult (Imaginary part)...\n",np.imag(arr)) आउटपुट
Our Array... [36.+5.j 27.+3.j 68.+2.j 23.+7.j] Dimensions of our Array... 1 Datatype of our Array object... complex128 Shape of our Array... (4,) Result (Imaginary part)... [5. 3. 2. 7.]