Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create reverse_numpy.py #32

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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))