First page Back Continue Last page Overview Graphics
Exercises
- Create a random vector v of size 10 with integer values between -8 and +8.
After this extract all the values, which are less than 0, into a new vector.
>>> v = np.random.randint(-8, 8, 10)
>>> v
array([ 0, -4, 1, -1, -3, -6, -1, 5, 5, 7])
>>> vp = v<=0
>>> vp
array([ True, True, False, True, True, True, True, False, False, False], dtype=bool)
>>> v[vp]
array([ 0, -4, -1, -3, -6, -1])
>>>