From c6ca0a8792b0321340f3e8d22811272b650a04e8 Mon Sep 17 00:00:00 2001 From: Mayur Manohar Patil Date: Wed, 30 Sep 2020 08:25:12 -0700 Subject: [PATCH] Create reverse_numpy.py --- reverse_numpy.py | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 reverse_numpy.py diff --git a/reverse_numpy.py b/reverse_numpy.py new file mode 100644 index 0000000..8a1b844 --- /dev/null +++ b/reverse_numpy.py @@ -0,0 +1,44 @@ +#Method 1: Using shortcut Method + +# Python code to demonstrate how to reverse numpy array using shortcut method + +import numpy as np + +# initialising numpy array +ini_array = np.array([1, 2, 3, 6, 4, 5]) + +# printing initial ini_array +print("initial array", str(ini_array)) + +# printing type of ini_array +print("type of ini_array", type(ini_array)) + +# using shortcut method to reverse +res = ini_array[::-1] + +# printing result +print("final array", str(res)) + + + + +Method 2: Using flipud function + +# Python code to demonstrate how to reverse numpy array using flipud method + +import numpy as np + +# initialising numpy array +ini_array = np.array([1, 2, 3, 6, 4, 5]) + +# printing initial ini_array +print("initial array", str(ini_array)) + +# printing type of ini_array +print("type of ini_array", type(ini_array)) + +# using flipud method to reverse +res = np.flipud(ini_array) + +# printing result +print("final array", str(res))