FunctionRacerProblemsRace

Diagonal From Values

BeginnerNumPyPython

Return a square 2-D array with len(values) rows and columns that has the numbers of values down its main diagonal (top-left to bottom-right) and 0 everywhere else. Hint: np.diag.

Example 1

values [4,5,6]
returns [[4,0,0],[0,5,0],[0,0,6]]

Row 0 is [4, 0, 0], row 1 is [0, 5, 0], row 2 is [0, 0, 6].

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More NumPy problems