Null Vector With a One
easynumpy_basicsImplement null_with_one(n, i).
Return a length-n vector of zeros (dtype float) whose value at index i
is 1. For example, null_with_one(10, 4) is a size-10 null vector whose
fifth value (index 4) is 1. No for/while loops.
Constraints
- no for/while loops
Your solution
Edit null_with_one and run the real pytest suite in your browser — no install required. Your code is saved locally.
Loading the Python runtime (first run only)…
Hints
Hint 1
Make a zero vector with np.zeros(n), then assign 1 to index i.