Q:

Write a NumPy program to convert an array to a float type

0

Write a NumPy program to convert an array to a float type

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

import numpy as np
import numpy as np
a = [1, 2, 3, 4]
print("Original array")
print(a)
x = np.asfarray(a)
print("Array converted to a float type:")
print(x)

Sample Output:

Original array                                                          
[1, 2, 3, 4]                                                            
Array converted to a float type:                                        
[ 1.  2.  3.  4.]

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now