About 50 results
Open links in new tab
  1. Generate random integers between 0 and 9 - Stack Overflow

    If you're restricted to the standard library, and you want to generate a lot of random integers, then random.choices() is much faster than random.randint() or random.randrange(). 2 For example to …

  2. python - How can I randomly select (choose) an item from a list (get a ...

    As of Python 3.6 you can use the secrets module, which is preferable to the random module for cryptography or security uses. To print a random element from a list:

  3. How to choose randomly between two values? - Stack Overflow

    Mar 28, 2019 · 14 I'm trying to get a piece of code to randomly choose between two values -40 and 40. To do so, I was thinking of using good old mathematics like - num = (-1) value · 40, where value is …

  4. Generate 'n' unique random numbers within a range [duplicate]

    Apr 3, 2014 · I know how to generate a random number within a range in Python. random.randint(numLow, numHigh) And I know I can put this in a loop to generate n amount of these …

  5. Choose random number without module in Python - Stack Overflow

    Jan 14, 2017 · Unless you want to write your own random number generator (which requires math than I can do in 5 minutes), you'll have to import something (numpy, random, pandas, etc).

  6. python - How to generate a random number with a specific amount of ...

    Jul 4, 2021 · 278 You can use either of random.randint or random.randrange. So to get a random 3-digit number:

  7. random - Randomly choose a number in a specific range with a specific ...

    Sep 14, 2011 · Again, that range is defined as 100:100:20000. Furthermore, by saying 'within that range', I don't mean randomly picking a number from 100->20000, such as 105. I mean randomly …

  8. Python choose random number in specific interval

    Feb 24, 2019 · I wondered, if there is random function that I can set with a specific interval between generated random numbers? Or should I try a different approach? And if so, how should I do it? I am …

  9. python - Random number between 0 and 1? - Stack Overflow

    May 15, 2022 · I want a random number between 0 and 1, like 0.3452. I used random.randrange(0, 1) but it is always 0 for me. What should I do?

  10. How do I perform a random event in Python by picking a random …

    Oct 22, 2010 · Let's say I have to variables, dog and cat. Dog = 5, and cat = 3. How would I tell Python to pick one of these variables by random and print it to the screen?