Not used for a system random number generator. Probably a good habit to use 001 for your first, 002 for the second. Tip: in the question title, start each question with the question order number. Check Quiz settings, Adding/updating a quiz under display settings, turn off shuffle questions. Well, yes you can pass it a "seed" argument, but you'll see that the SystemRandom object simply ignores it: def seed(self, *args, **kwds): Re: Random selection of questions from a question pool. You can pass a seed to SystemRandom, too. If you fix the seed, you will get the reproducible results - and that's what seed is designed for. While this tool isnt a word creator, it is a word generator that will generate random words for a variety of activities or uses. This is not about whether random.choice is truly random or not. Random Word Generator is the perfect tool to help you do this. > ed(42) random.choice(foo), random.choice(foo), random.choice(foo) It seems random, but it's actually not, which we can see if we reseed it repeatedly: > ed(42) random.choice(foo), random.choice(foo), random.choice(foo) Is it weird stuff Also, there's a different picker tool for getting multiple random items from your list if that's what you're after. I wonder what type of things you're entering in the list. If you want a deterministic pseudorandom selection, use the choice function (which is actually a bound method on a Random object): > random.choice Random Selector Just enter your list items and the tool will be the chooser / picker / selector you've been yearning for. The above is equivalent to my former recommendation, using a SystemRandom object from the random module with the choice method - available earlier in Python 2: > import random # Python 2 compatible If you want close to truly random, then I suggest secrets.choice from the standard library (New in Python 3.6.): > from secrets import choice # Python 3 only What is the simplest way to retrieve an item at random from this list? both the seed and the spawn-tree-path, down to a 128-bit pool by default. How to randomly select an item from a list?Īssume I have the following list: foo = The above streams can be spawned directly from a parent generator via spawn. If you want to randomly select more than one item from a list, or select an item from a set, I'd recommend using random.sample instead.
0 Comments
Leave a Reply. |