About 1,060,000 results
Open links in new tab
  1. python - Generate random integers between 0 and 9 - Stack …

    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 …

  2. What does `random.seed()` do in Python? - Stack Overflow

    234 I am a bit confused on what random.seed() does in Python. For example, why does the below trials do what they do (consistently)?

  3. python - How to generate a random number with a specific …

    Jul 4, 2021 · 278 You can use either of random.randint or random.randrange. So to get a random 3-digit number: from random import randint, randrange randint(100, 999) # randint is inclusive …

  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 …

  5. python - What is the difference between random.randint and …

    The reason is historical: randint was added early in v1.5 circa 1998 and this function name was used for generating both random floating-point numbers randomly and integers randomly …

  6. Python random numbers multiple times - Stack Overflow

    rnumber = random.randint(number1, number2) print (rnumber) main() I am messing around in Python, and I want my program to generate random numbers. As you can see I have already …

  7. Generate a random letter in Python - Stack Overflow

    Is there a way to generate random letters in Python (like random.randint but for letters)? The range functionality of random.randint would be nice but having a generator that just outputs a …

  8. Generate random number in range excluding some numbers

    Mar 24, 2017 · Is there a simple way in Python to generate a random number in a range excluding some subset of numbers in that range? For example, I know that you can generate a random …

  9. python - How to generate random integers with multiple ranges?

    Nov 16, 2015 · 0 for i in (randint(1,5),randint(9,15),randint(21,27)): print i This foor loop will generate 3 random numbers one from the first range supplied, another for second range and …

  10. How do I create a list of random numbers without duplicates?

    Mar 18, 2012 · I tried using random.randint(0, 100), but some numbers were the same. Is there a method/module to create a list unique random numbers?