About 1,040,000 results
Open links in new tab
  1. random iteration in Python - Stack Overflow

    Feb 12, 2012 · You can use random.shuffle() to, well, shuffle a list: import random r = list(range(1000)) random.shuffle(r) for i in r: # do something with i By the way, in many cases …

  2. Python random numbers loop - Stack Overflow

    Nov 23, 2013 · Here is the right one set. b = 0. c = set() while len(c) < 5: c.add(randint(1, 5)) b += 1. a.append(b) # Import the `randint` function from `random`. # This will hold the results that …

  3. python - How to create a random list of numbers using a random.randint ...

    Oct 17, 2017 · Building off of @COLDSPEED's comment, if you want a list of 20 number different random numbers between -500 and 500. You can use a while loop to build a set of the random …

  4. Generating random number list in Python - GeeksforGeeks

    Jan 27, 2025 · For example, we might want to create a list of 5 random numbers ranging from 1 to 100. This article explores different methods to generate a random number list in Python. Using …

  5. Python - Generate random numbers within a given range and …

    Nov 19, 2024 · To generate a random numbers list in Python within a given range, starting from ‘start’ to ‘end’, we will use random module in Python. Python provides a function named …

  6. Python Random randint () Method - W3Schools

    Definition and Usage The randint() method returns an integer number selected element from the specified range.

  7. Python Random - random() Function - GeeksforGeeks

    Apr 26, 2023 · The random () method in Python from the random module generates a float number between 0 and 1. Here, we are using Python Loop and append random numbers in …

  8. random — Generate pseudo-random numbers — Python 3.13.3 …

    2 days ago · This module implements pseudo-random number generators for various distributions. For integers, there is uniform selection from a range. For sequences, there is …

  9. 5 Best Ways to Generate Random Numbers within a Given Range …

    Mar 11, 2024 · In this snippet, we use a list comprehension that runs a loop 10 times, calling random.randint(1, 50) for each iteration and collecting the results in a new list. It’s a more …

  10. Generating Multiple Random Numbers in Python - CodeRivers

    6 days ago · The random module in Python provides the randint() function to generate random integers within a specified range (inclusive of both endpoints). To generate multiple random …

  11. Some results have been removed
Refresh