Using np.random.default_rng() to Generate Random Numbers
📖 Scenario: Imagine you are a data scientist who needs to generate random numbers for a simulation. Using the modern np.random.default_rng() method helps you create random numbers in a simple and reliable way.
🎯 Goal: You will create a random number generator, set a seed for reproducibility, generate a list of random integers, and then print the list.
📋 What You'll Learn
Create a random number generator using
np.random.default_rng()Set the seed to
123 for reproducibilityGenerate 5 random integers between 10 and 50 (inclusive)
Print the list of generated random integers
💡 Why This Matters
🌍 Real World
Random number generation is used in simulations, games, and testing to create unpredictable but reproducible data.
💼 Career
Data scientists and analysts use random number generators to create sample data, run simulations, and test models.
Progress0 / 4 steps