1. Help Center
  2. Python Programming

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)