- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# Return a new array of given shape and type, filled with array-like in Numpy

To return a new array of given shape and type, filled with a fill value, use the **numpy.full()** method in Python Numpy. The 1st parameter is the shape of the new array. The 2nd parameter sets the fill value as array-like.

The dtype is the desired data-type for the array. The order suggests whether to store multidimensional data in C- or Fortran-contiguous (row- or column-wise) order in memory.

NumPy offers comprehensive mathematical functions, random number generators, linear algebra routines, Fourier transforms, and more. It supports a wide range of hardware and computing platforms, and plays well with distributed, GPU, and sparse array libraries.

## Steps

At first, import the required library −

import numpy as np

To return a new array of given shape and type, filled with a fill value, use the numpy.full() method. The 2nd parameter sets the fill value as array-like −

arr = np.full((2, 2), fill_value = [998, 999])

Display the array −

print("Array...\n",arr)

Get the type of the array −

print("\nArray datatype...\n",arr.dtype)

Get the dimensions of the Array: −

print("\nArray Dimensions...\n",arr.ndim)

Get the shape of the array −

print("\nOur Array Shape...\n",arr.shape)

Get the number of elements of the Array −

print("\nElements in the Array...\n",arr.size)

## Example

import numpy as np # To return a new array of given shape and type, filled with a fill value, use the numpy.full() method in Python Numpy # The 1st parameter is the shape of the new array # The 2nd parameter sets the fill value as array-like arr = np.full((2, 2), fill_value = [998, 999]) # Displaying our array print("Array...\n",arr) # Get the datatype print("\nArray datatype...\n",arr.dtype) # Get the dimensions of the Array print("\nArray Dimensions...\n",arr.ndim) # Get the shape of the Array print("\nOur Array Shape...\n",arr.shape) # Get the number of elements of the Array print("\nElements in the Array...\n",arr.size)

## Output

Array... [[998 999] [998 999]] Array datatype... int64 Array Dimensions... 2 Our Array Shape... (2, 2) Elements in the Array... 4

- Related Questions & Answers
- Return a new array of given shape and type filled with a fill value in Numpy
- Return a new array of given shape filled with ones in Numpy
- Return a new array of given shape filled with zeros in Numpy
- Return a new array of a given shape filled with ones in Numpy
- Return a new array of given shape filled with a fill value and a different output type in Numpy
- Return a new array of given shape filled with ones and also set the desired data-type in Numpy
- Return a new array with the same shape and type as given array in Numpy
- Return a new array of given shape filled with ones but with different datatype in Numpy
- Return a new array with the same shape and type as a given array in Numpy
- Return a new array of given shape and type without initializing entries in Numpy
- Return a new array of given shape filled with zeros and also set the desired datatype in Numpy
- Return a new array of given shape filled with zeros and also set the desired output in Numpy
- Return a new array with the same shape and type as a given array and change the order in Numpy
- Return a full array with the same shape and type as a given array in Numpy
- Return an array of ones with the same shape and type as a given array in Numpy