Interview Questions

How do I generate random numbers in Python?

Python Questions and Answers


(Continued from previous question...)

How do I generate random numbers in Python?

The standard module random implements a random number generator. Usage is simple:

import random
random.random()

This returns a random floating point number in the range [0, 1).

(Continued on next question...)

Other Interview Questions