Skip to content
Home » randint() Python

randint() Python

In Python3, randint() is a built-in function of the random module. The random module provides access to a number of useful functions, one of which is the ability to create random numbers (randint).

Syntax:

randint(start , end+1)

import random  
n = random.randint(50,150)  
print(n)  

Output:

95

Note: You should provide only integers as an arguments in randint. If you provide floating point values or any string characters as an arguments you will end up with an error.

Also Read:

Generate List of random numbers using Loop : Python