Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions reverse_numpy.py
Original file line number Diff line number Diff line change
@@ -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))