232k views
3 votes
This function in the random module returns multiple, nonduplicated random elements from a list.

a. choice
b. choices
c. sample
d. random_element

User Fmessina
by
7.3k points

1 Answer

7 votes

Final answer:

The function from the random module that returns nonduplicated random elements from a list is 'sample'. It allows you to select a specified number of unique elements from a list.

Step-by-step explanation:

The function in the random module that returns multiple, nonduplicated random elements from a list is sample. This function allows you to specify the number of unique elements you want to obtain from a given list. It is important to note that the list you are sampling from must have at least as many elements as you want to sample, otherwise you will get an error because the function cannot return more unique elements than exist in the list.

The correct function in the random module that returns multiple, nonduplicated random elements from a list is the sample function. This function takes two arguments: the list and the number of elements to be selected. It returns a new list containing the randomly selected elements without any duplicates. For example, if you have a list of numbers [1, 2, 3, 4, 5] and you want to select 3 random numbers from it, you can use the sample function like this.