0 votes
in Python by
explain numpy.full() in Python

1 Answer

0 votes
by
numpy.full() in Python The full() method of Python numpy class returns a new array of specified shape and type, filled with fill_value. Syntax

numpy.full(shape, fill_value, dtype=None, order='C')

Parameter shape:This parameter represents the number of rows order :The order parameter can be either C_contiguous or F_contiguous.dtype :It is an optional parameter. It depicts the data type of returned array, and by default, it is a float. fill_value :It represents the value to fill in the array. It is an optional parameter, by default it is Boolean. Return This method returns a new array with the same shape and type as a given array that is filled with fill_value. Example 1

# Python Programming giving an example for

# numpy.full() method

importnumpy as numpy

obj1 = numpy.full([2, 2], 17, dtype = int)

print("\nFirst Matrix : \n", obj1)

obj2 = numpy.full([3, 3], 11.9)

print("\nSecond Matrix : \n", obj2)

Output First Matrix :

 [[17 17]

[17 17]]

Second Matrix :

 [[ 11.9  11.9  11.9]

[ 11.9  11.9  11.9]

[ 11.9  11.9  11.9]]
...