Tutorials Point


  Python Basics
  Python Advanced
  Python Useful References
  Python Useful Resources
  Selected Reading

© 2011 TutorialsPoint.COM


  Home     References     Discussion Forums     About TP  

Python Number random() Function


previous next AddThis Social Bookmark Button


Description:

This function returns a random float r, such that 0 is less than or equal to r and r is less than 1

Syntax:

random ( )

Note: This function is not accessible directly so we need to import random module and then we need to call this function using random static object.

Parameters:

Here is the detail of parameters:

  • NA

Return Value:

A random float r, such that 0 is less than or equal to r and r is less than 1.

Example:

#!/usr/bin/python
import random

# First random number
print "random() : ", random.random()

# Second random number
print "random() : ", random.random()

This will produce following result:

random() :  0.281954791393
random() :  0.309090465205


previous next Printer Friendly



  

Advertisement

Online Image Processing

Indian Baby Names