# Python program to find the smallest number in a NumPy array

In this tutorial, we are going to show **how to find the smallest number in a NumPy array in python** by using different methods. NumPy is a multidimensional array and NumPy doesn’t have append function in their library (in python for one-dimensional array there is append function are present) hence for finding the smallest number in NumPy array we used their inbuilt function. For creating an array in NumPy there are two main functions available and functions are listed below.

**arange()****linspace()**

## Find the smallest number in a NumPy array using arange() function

**Explanation:**

- Importing all the functions of the NumPy array by using ‘*’ indication. (header file )
- ‘s’ is int type array variable, as well as arange function, generate the array which starts from 3 & ending before 20. ( 20 is excluded ) and 4 is the number that creates a gap between 3 to 20 by 4.(in this array all elements have the same gap by 4 ).
- print array.
- printing the smallest number present in the array.

from numpy import * s=arange(3,20,4) print("array is:",s) print("Smallest number in array:",min(s))

Output:

array is: [ 3 7 11 15 19] Smallest number in array: 3

## using linspace() function

**Explanation:**

- Importing all the functions of the NumPy array by using ‘*’ indication. (header file )
- ‘s’ is float type array variable, as well as linspace function, generate the array which starts from 3 & ending at 20. ( 20 is included ) and 6 is the number that creates a gap between 3 to 20 by 6.(in this array all elements have the same gap by 6 ).
- print array.
- printing the smallest number present in the array.

from numpy import * s=linspace(3,20,6) print("array is:",s) print("Smallest number in array:",min(s))

Output:

array is: [ 3. 6.4 9.8 13.2 16.6 20. ] Smallest number in array: 3.0

You may also read:

## Leave a Reply