🚀 Hurry! Offer Ends In
00 Days
00 Hours
00 Mins
00 Secs
Enroll Now
X

निम्नलिखित कोड का परिणाम क्या है ?

What is the output of the following code ?

import numpy as np
a = np.array([1.1,2,3])
print(a.dtype)
A)
B)
C)
D)

Explanation:

Let's break down the code:

import numpy as np
a = np.array([1.1, 2, 3])
print(a.dtype)

Explanation:

  1. Creating the array:

    • a = np.array([1.1, 2, 3]) creates a NumPy array. The array contains a mix of float (1.1) and int (2 and 3).
  2. NumPy Array Type Promotion:

    • NumPy automatically promotes the data type of the array to a common type that can hold all the values. Since there is a float (1.1), NumPy will convert the entire array to the float64 data type to accommodate the decimal values.
  3. a.dtype:

    • This returns the data type of the elements in the array. Since the array contains a float, the dtype will be float64.

Conclusion:

The output will be float64.

Answer:

(B) float64

Latest Updates