3 random numbers from the measurement in python

To generate 3 random numbers from a given measurement data in Python, we can use the random.sample() function from the random module.

Here's an example code snippet:

main.py
import random

# Sample measurement data
measurement_data = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]

# Generate 3 random numbers from the measurement data
random_numbers = random.sample(measurement_data, 3)

print(random_numbers)
232 chars
10 lines

Output:

main.py
[10, 80, 70]
13 chars
2 lines

In this example, we first define the measurement data as a list [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]. Then, we use the random.sample() function to generate 3 random numbers from this list. The output of the program will be a list of 3 randomly selected numbers from the original measurement data.

Note that the random.sample() function ensures that the selected numbers are unique and not duplicates.

gistlibby LogSnag