Q:

Write a NumPy program to create a new array of 3*5, filled with 2

0

Write a NumPy program to create a new array of 3*5, filled with 2

All Answers

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

import numpy as np
#using no.full
x = np.full((3, 5), 2, dtype=np.uint)
print(x)
#using no.ones
y = np.ones([3, 5], dtype=np.uint) *2
print(y)

Sample Output:

[[2 2 2 2 2]                                                           
 [2 2 2 2 2]                                                           
 [2 2 2 2 2]]                                                          
[[2 2 2 2 2]                                                           
 [2 2 2 2 2]                                                           
 [2 2 2 2 2]]

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