Reading Time: 1 minutes
Generate 10 random even numbers in Python
Write a Python program to generate 10 random even numbers from 0 to 100.
generate 10 random even numbers from 0 to 100
import random # list of even numbers between 0 and 100 bucket = [number for number in range(0, 101) if number % 2 == 0] tenEvenRandomNumbers = random.sample(bucket, 10) print(tenEvenRandomNumbers) # [42, 58, 48, 64, 82, 6, 54, 100, 78, 44]