Write a Program in Python to find Random Numbers.
Random Number Using for loop
The randint() function with loop can be used to produce a list of random numbers. Step 1: Create an empty list Step 2: Append the random numbers produced to the empty list one by one.
1 2 3 4 5 6 |
import random rand_list = [] for i in range(0,20): n = random.randint(1,50) rand_list.append(n) print(rand_list) |
1 2 3 4 5 6 |
import random rand_list = [] for i in range(30,33): n = random.randint(1,50) rand_list.append(n) print(rand_list) |