Answers for "np.ones() in python 3"

4

numpy ones

import numpy
print(numpy.ones((2, 3), dtype=int))
# creates the array of the shape (2, 3) of value 1 in its each cell
print(numpy.ones(6, dtype=str) 
# creates an array of size 6 with values of '1'
Posted by: Guest on April-15-2021

Python Answers by Framework

Browse Popular Code Answers by Language