-
-
Save IndhumathyChelliah/31aade5af9d90ec10950269910ac8365 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
a1=np.array([[0,1,2,3],[4,5,6,7],[8,9,10,11],[12,13,14,15]]) | |
print (a1) | |
#Output: | |
[[ 0 1 2 3] | |
[ 4 5 6 7] | |
[ 8 9 10 11] | |
[12 13 14 15]] | |
#Accessing elements which are greater than 5 | |
print (a1[a1>5]) | |
#Output:[ 6 7 8 9 10 11 12 13 14 15] | |
#Accessing elements which are greater than 5 and less than 10 | |
print (a1[(a1>5)&(a1<10)]) | |
#Output:[6 7 8 9] | |
#Modifying elements which are greater than 11 by adding 100 to it. | |
a1[a1>11]+=100 | |
print (a1) | |
#Output: | |
[[ 0 1 2 3] | |
[ 4 5 6 7] | |
[ 8 9 10 11] | |
[112 113 114 115]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment