Skip to content
CampusEduX

Problem 1: Generate Reproducible Random Data

Easypython
Learn the Concept: NumPy (Condensed Reference)

Problem Description

Write a Python program that uses np.random.default_rng() with a fixed seed to generate 5 random numbers, and confirms that running it twice produces identical results.

Input

A seed value.

Output

The generated random numbers from two separate runs, showing they match.

Constraints

  • Use the same seed both times.

Example Input

text
seed=42

Example Output

text
Run 1: [0.305 -1.04 0.75 0.94 -1.95] Run 2: [0.305 -1.04 0.75 0.94 -1.95] Match: True

Concepts Covered

np.random.default_rng(), reproducibility.

Related Problems

  • Problem 2: Filter Data Using Boolean Masking
    Easy · python
    Solve Problem
  • Problem 3: Select Specific Elements Using Fancy Indexing
    Easy · python
    Solve Problem
  • Problem 4: Calculate a Matrix's Inverse and Verify It
    Easy · python
    Solve Problem

Input (stdin)

Output

Run your code to see output here...