# Python Random Numbers Generation

By | July 30, 2022

The process of Python Random Numbers Generation is very simple and easy to understand.

## Steps To Generate a Random Number in Python 1. Import random module

2. Use randint() method of random module to generate an integer number within a specific range.

Example: Generate a Random Number Between 1 and 50

```import random
n = random.randint(1,50);
print(n)
```

```44
```

### Python Program To Generate 20 Random numbers in range of 1 to 10

We will use a for loop to generate 20 random numbers. The for loop will use the range(1,21) function for 20 iterations.

```# Python program to generate 5 random numbers between 1 and 10

import random
num_list = []
for i in range(1,21):
n = random.randint(1,10);
num_list.append(n)

print("5 Random numbers between 1 to 10 are:")
print(num_list)
```

### Output

```20 Random numbers between 1 to 10 are:
[2, 4, 4, 1, 4, 9, 4, 9, 8, 9, 7, 6, 6, 7, 9, 10, 5, 9, 9, 2]

```

## Python GUI ( Graphcal User Interface ) Programs using tkinter Module Python GUI ( Graphcal User Interface ) Programs using tkinter Module 