Python Basics
Python Advanced
Python Useful References
Python Useful Resources
Selected Reading
© 2011 TutorialsPoint.COM
|
Python Number seed() Function
Description:
This function sets the integer starting value used in generating random numbers. Call this function before calling any other random module function.
Syntax:
Note: This function is not accessible directly so we need to import seed module and then we need to call this function using random static object.
Parameters:
Here is the detail of parameters:
Return Value:
Returns None.
Example:
#!/usr/bin/python
import random
random.seed( 10 )
print "Random number with seed 10 : ", random.random()
# It will generate same random number
random.seed( 10 )
print "Random number with seed 10 : ", random.random()
# It will generate same random number
random.seed( 10 )
print "Random number with seed 10 : ", random.random()
|
This will produce following result:
Random number with seed 10 : 0.57140259469
Random number with seed 10 : 0.57140259469
Random number with seed 10 : 0.57140259469
|
|
|
|