Python NumPy: Array converted to a float type
Python NumPy: Array Object Exercise-7 with Solution
Write a Python program to an array converted to a float type.
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)
Original array [1, 2, 3, 4] Array converted to a float type: [ 1. 2. 3. 4.]
Python Code Editor:
Improve this sample solution and post your code through Disqus