How can I randomly output the multiple of 600 numbers in python? I want to output 10 numbers, minimum number is 1000 and maximam is 34000

python

You can use the random module in Python to generate a list of random numbers that are multiples of 600 within the specified range of 1000 to 34000, and then select 10 numbers from that list using the sample() function. Here’s an example code snippet:

import random
# Generate a list of multiples of 600 within the range of 1000 to 34000
multiples_of_600 = [num for num in range(1000, 34001) if num % 600 == 0]

# Select 10 random numbers from the list
random_numbers = random.sample(multiples_of_600, 10)

# Print the random numbers
print(random_numbers)

This code will output a list of 10 random numbers that are multiples of 600 and within the specified range. You can adjust the range and the number of random numbers generated as needed.

コメント

Copied title and URL