//Generate a Random Integer in Python

Generate a Random Integer in Python

In this example we can see how to generate a random number in Python.

import random
x = random.randint(0,200)
print x

In the first row we import Python random module. It’s contains different useful functions to generate random numbers. In the second row we use function randint from the imported module to generate integer between 0 and 200 and assign it to variable x. In the last row we print the integer on the screen.

By |2017-11-25T22:19:08+00:00November 25th, 2017|Categories: How To|Tags: , |0 Comments

Leave A Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.