Python Generate Random Number Between 1 and 10 Example

By Hardik Savani October 30, 2023 Category : Python

Hey Dev,

This is a short guide on python generate random number between 1 and 10. you will learn python get random number between 1 and 10. Here you will learn how do you generate a random number between 1 and 10 in python. It's a simple example of python program to generate a random number between 1 and 10.

In this example, we will use random library to generate random number between 1 to 10 in python. we will create random number between 1 to 10 from python code. let's see a simple example.

You can use these examples with python3 (Python 3) version.

let's see below a simple example with output:

Example 1:

main.py

import random
  
# Generate Random Number in Python
randomNumber = random.randint(1,10)
print(randomNumber)

Output:

7

I hope it can help you...

Tags :
Shares