Python program to reverse a Numpy array?

PythonNumpyServer Side ProgrammingProgramming

This is a simple program wherein we have to reverse a numpy array. We will use numpy.flip() function for the same.


Step 1: Import numpy.
Step 2: Define a numpy array using numpy.array().
Step 3: Reverse the array using numpy.flip() function.
Step 4: Print the array.

Example Code

import numpy as np

arr = np.array([10,20,30,40,50])
print("Original Array: 
", arr) arr_reversed = np.flip(arr) print("
Reversed Array:
", arr_reversed)


Original Array:
[10 20 30 40 50]

Reversed Array:
[50 40 30 20 10]
Updated on 16-Mar-2021 10:42:12