Python - Generate a Random Number

In this program, you will learn how to generate a random number.


Program: Generate a Random Number



    # This program to generate the random numbers

    import random
    
    x = random.randint(10,20)
    
    print('The generated random number is {}'.format(x))
            
            

Output


    The generated random number is 12
            

In this program, we have used randint function from random module.

You may get different output because this program generates random number in range between 10 and 20.



The following topics can be useful to understand this program.



Related Tutorials