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.py232 chars10 lines
Output:
main.py13 chars2 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