increased range of array to (1, 21) and added comparison of array % 2 == 0
This commit is contained in:
parent
d8adc75a00
commit
37939965d2
@ -1,6 +1,6 @@
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
# Creating an array of integers from 1 to 10 inclusive
|
# Creating an array of integers from 1 to 10 inclusive
|
||||||
array = np.arange(1, 11)
|
array = np.arange(1, 21)
|
||||||
# Retrieving elements greater than or equal to 5 AND less than 9
|
# Retrieving elements greater than or equal to 5 AND less than 9
|
||||||
print(array[(array >= 5) & (array < 9)])
|
print(array[(array >= 5) & (array < 9)])
|
||||||
# Retrieving elements less than or equal to 4 AND not equal to 2
|
# Retrieving elements less than or equal to 4 AND not equal to 2
|
||||||
@ -9,6 +9,7 @@ print(array[(array != 2) & (array <= 4)])
|
|||||||
print(array[(array < 3) | (array == 8)])
|
print(array[(array < 3) | (array == 8)])
|
||||||
# Retrieving elements between 2 inclusive AND 5 inclusive OR equal to 9
|
# Retrieving elements between 2 inclusive AND 5 inclusive OR equal to 9
|
||||||
print(array[(array >= 2) & (array <= 5) | (array == 9)])
|
print(array[(array >= 2) & (array <= 5) | (array == 9)])
|
||||||
|
print(array[(array % 2 == 0)])
|
||||||
|
|
||||||
'''
|
'''
|
||||||
If both conditions are true, | returns True, otherwise returns False.
|
If both conditions are true, | returns True, otherwise returns False.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user