How to Generate a Random Number Between 1 and 10 in Python 3
Let’s see how to get a random number between 1 and 10 in python 3 using the
randint() function of the
random module returns a random number between two given numbers. To get a random number between 1 and 10, pass 1 and 10 as the first and second arguments, respectively.
#!/usr/bin/python3 import random random_number = random.randint(1, 10) print(random_number)
The above Python code will return a random integer between 1 and 10 each time you run the program (including 1 and 10).
So that is how we can generate a random number between 1 and 10 in python 3.