- Write A Python Function Negposzero Which Takes A Numpy Array X As Its Input Argu Ment For Each Element Of The Array 1 (59.69 KiB) Viewed 17 times
Write a Python function negposzero () which takes a numpy array x as its input argu- ment. For each element of the array
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
Write a Python function negposzero () which takes a numpy array x as its input argu- ment. For each element of the array
Write a Python function negposzero () which takes a numpy array x as its input argu- ment. For each element of the array x, your function should display: the string "negative" if the element is negative (< 0) the string "positive" if the element is positive (>0) the string "zero" if the element is zero (0) Your code for function negposzero () should be within a Python script following the format shown below, in which you are asked to write the code for negposzero (): import numpy as np def negposzero (x): #your function code here np. random seed (1) x = np. random. randint (-5, 5, size=10) print (x) negposzero (x) When implemented correctly, your Python script should generate the output below. While the sample output is shown below for a particular choice of x. your function should work for arrays x of any length. [0340-5-5-42 14] zero positive positive negative. negative negative positive positive.