Random Numbers & File I/O
Reproducible randomness with Generator, plus reading/writing arrays.
Prefer the modern Generator API (np.random.default_rng) over the
legacy np.random.seed/np.random.rand: it's the recommended approach in
current NumPy and gives each generator its own independent state.
For file I/O, NumPy's functions happily accept an in-memory buffer
(io.BytesIO/io.StringIO) as well as a real filename, handy for tests or
whenever there's no real filesystem to write to.
📝 Note: np.loadtxt is fast but fails outright on any missing value; np.genfromtxt is slower but tolerates and fills gaps. Reach for genfromtxt on messy real-world data.
Now practice it
Exercises that use what this lesson just covered.