﻿ NumPy: Select indices satisfying multiple conditions in a numpy array - w3resource NumPy: Select indices satisfying multiple conditions in a numpy array

NumPy: Array Object Exercise-92 with Solution

Write a NumPy program to select indices satisfying multiple conditions in a numpy array.
Sample array:
a = np.array([97, 101, 105, 111, 117])
b = np.array(['a','e','i','o','u'])

Note: Select the elements from the second array corresponding to elements in the first array that are greater than 100 and less than 110

Pictorial Presentation: Sample Solution:

Python Code:

``````import numpy as np
a = np.array([97, 101, 105, 111, 117])
b = np.array(['a','e','i','o','u'])
print("Original arrays")
print(a)
print(b)
print("Elements from the second array  corresponding to elements in the first array  that are greater than 100 and less than 110:")
print(b[(100 < a) & (a < 110)])
```
```

Sample Output:

```Original arrays
[ 97 101 105 111 117]
['a' 'e' 'i' 'o' 'u']
Elements from the second array  corresponding to elements in the first
array  that are greater than 100 and less than 110:
['e' 'i']
```

Python Code Editor:

Have another way to solve this solution? Contribute your code (and comments) through Disqus.

What is the difficulty level of this exercise?

﻿

New Content: Composer: Dependency manager for PHP, R Programming

bedava porno