how to create a numpy array with constant value

Solutions on MaxInterview for how to create a numpy array with constant value by the best coders in the world

we are a community of more than 2 million smartest coders
registration for
employee referral programs
are now open
get referred to google, amazon, flipkart and more
register now
  
showing results for - "how to create a numpy array with constant value"
Jayda
20 Jan 2017
1>>> np.full((3, 5), 7)
2array([[ 7.,  7.,  7.,  7.,  7.],
3       [ 7.,  7.,  7.,  7.,  7.],
4       [ 7.,  7.,  7.,  7.,  7.]])
5
6>>> np.full((3, 5), 7, dtype=int)
7array([[7, 7, 7, 7, 7],
8       [7, 7, 7, 7, 7],
9       [7, 7, 7, 7, 7]])
10