Consolidation - numpy riddles

Solve the following numpy riddles using numpy and its documentation.

If possible, work in the pair programming paradigm: work in pairs, with one person taking the role of the driver (writing the code) and one taking the role of the navigator (reading and understanding the documentation). Alternate the roles. Try to find solutions that are short (i.e. few line sof code) but easy to understand.

Diagonal Sum:

Unique Elements Count:

Random sample ands cumulative sum:

Rolling Window:

Hint: you can use list comprehension and convert the final list to an array.

Product of elements:

Vectorised calculations and visualisation:

Hint1: disk point picking is not trivial: https://mathworld.wolfram.com/DiskPointPicking.html

Hint2: For matplotlib’s plot, use the pixel style ',', and remmber to set the axis to be in the same units ("equal")