Python Slicing Semantics: Bounds, Steps, Aliases and Views

Reported in interviews at Arrowstreet Capital

Problem statement

How do Python slices behave, and when do they share data? Work through list slicing, aliases, and NumPy views without running the code. State each requested output, starting afresh in each part.

Show hint

For each slice, what concrete start index, stop index and direction does it resolve to on a length-six list?

Relevant roles: ML Engineer, Forward Deployed Engineer, AI Engineer and Data Scientist.

Related free problems