Skip to content
English
  • There are no suggestions because the search field is empty.

How would you generate random numbers in python?

To generate random numbers in Python, you must first import the random module.
 
The random() function generates a random float value between 0 & 1.
 
> random.random()

 

The randrange() function generates a random number within a given range.

 

Syntax: randrange(beginning, end, step)

 

Example - > random.randrange(1,10,2)