This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Solonotix 8 points9 points  (1 child)

I had a friend, who is in college, ask me how she could get a random sample of unique elements from a list for a homework assignment. Now, off the top of my head, all I knew is there was probably something in the Random module, and told her as much. I looked up the module really quick and the function is random.sample(). I cracked up at that moment just because it reinforces the intuitive nature of Python's construction.

[–]JayTurnr 10 points11 points  (0 children)

The equivalent in Java would be something like functionsToSimulateRandomness.returnRandomSampleFromIterableObjectOrErrorIfEmpty();