जटिल तर्क के वास्तविक भाग को वापस करने के लिए, पायथन में numpy.real() विधि का उपयोग करें। Themethod जटिल तर्क का वास्तविक घटक देता है। यदि वैल वास्तविक है, तो आउटपुट के लिए वैल के प्रकार का उपयोग किया जाता है। यदि वैल में जटिल तत्व हैं, तो लौटा हुआ प्रकार फ्लोट है। पहला पैरामीटर, वैल इनपुट ऐरे है
कदम
सबसे पहले, आवश्यक पुस्तकालयों को आयात करें -
import numpy as np
सरणी () विधि का उपयोग करके एक सरणी बनाएं -
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)
जटिल तर्क के वास्तविक भाग को वापस करने के लिए, पायथन में numpy.real() विधि का उपयोग करें। Themethod जटिल तर्क का वास्तविक घटक देता है। यदि वैल वास्तविक है, तो आउटपुट के लिए वैल के प्रकार का उपयोग किया जाता है। यदि वैल में जटिल तत्व हैं, तो लौटा हुआ प्रकार फ्लोट है। पहला पैरामीटर, वैल इनपुट ऐरे है -
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)) आउटपुट
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.]