What is the around function in numpy?
The around function is used to round an array of floats to a given number of decimals. It comes with numpy, which is a widely used library of the high-level programming language Python.
To use the around function, the around library must be imported at the program’s start.
import numpy
Syntax
numpy.around(a, decimals=0, out=None)
Parameters
The around function takes in the following parameters:
a- an array of floats on which thearoundfunction will be applied.decimals- (optional) the number of decimals to which the values inawill be rounded. By default, its value is 0.out- (optional) the location where the return value of thearoundfunction will be stored.
Return value
The around function returns an array with the same dimension as that of ``and contains rounded values of type float.
If
acontains complex numbers, the real and imaginary parts are rounded separately.
Example
The following example demonstrates how to round an array of floats up to 3 and subsequently 4 decimal numbers.
The return value is printed using the built-in print function, which comes with Python.
import numpyprint(numpy.around([2.51231, 6.12351, -6123.123123], 3))print(numpy.around([2.51231, 6.12351, -6123.123123], 4))
Free Resources
Copyright ©2026 Educative, Inc. All rights reserved