Q:

Write a NumPy program to create an array of equal shape and data type of a given array

0

Write a NumPy program to create an array of equal shape and data type of a given array.
Fill the new array with 0.0.

All Answers

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

import numpy as np  
nums = np.array([[5.54, 3.38, 7.99],
              [3.54, 8.32, 6.99],
              [1.54, 2.39, 9.29]])
print("Original array:")
print(nums)
print("\nNew array of equal shape and data type of the said array filled by 0:")
print(np.zeros_like(nums))

Sample Output:

Original array:
[[5.54 3.38 7.99]
 [3.54 8.32 6.99]
 [1.54 2.39 9.29]]

New array of equal shape and data type of the said array filled by 0:
[[0. 0. 0.]
 [0. 0. 0.]
 [0. 0. 0.]]

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