About 92,400 results
Open links in new tab
  1. python - Generate random integers between 0 and 9 - Stack Overflow

    While many posts demonstrate how to get one random integer, the original question asks how to generate random integer s (plural): How can I generate random integers between 0 and 9 (inclusive) …

  2. 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:

  3. python - Generate random number between x and y which is a …

    Oct 2, 2024 · import random print random.randrange(10, 25, 5) This prints a number that is between 10 and 25 (10 included, 25 excluded) and is a multiple of 5. So it would print 10, 15, or 20.

  4. python - How do I Assign a random number to a variable? - Stack …

    Mar 19, 2014 · I've tried mucking around with things like Str = random.randomint(1,18), using the random module. The closest I've come is using the lambda function, so that when I call up the …

  5. python - 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?

  6. 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 …

  7. python - How to generate random numbers by a certain step ... - Stack ...

    Nov 12, 2021 · For school we have to create a program in python in which we generate a given number of random numbers and you can choose by what multiplication. I tried this code (which will show my …

  8. Python: Random numbers into a list - Stack Overflow

    8 Here I use the sample method to generate 10 random numbers between 0 and 100. Note: I'm using Python 3's range function (not xrange).

  9. python - Pandas: create new column in df with random integers from ...

    May 19, 2015 · To use it, construct the numpy.random.default_rng() and call the appropriate method e.g. integers, choice, normal, standard_normal etc. The following is an example where len(df1) number of …

  10. python - How to generate a random normal distribution of integers ...

    May 25, 2016 · 49 How to generate a random integer as with np.random.randint(), but with a normal distribution around 0. np.random.randint(-10, 10) returns integers with a discrete uniform distribution …