
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
- Python Advanced Tutorial
- Python - Classes/Objects
- Python - Reg Expressions
- Python - CGI Programming
- Python - Database Access
- Python - Networking
- Python - Sending Email
- Python - Multithreading
- Python - XML Processing
- Python - GUI Programming
- Python - Further Extensions
- Python Useful Resources
- Python - Questions and Answers
- Python - Quick Guide
- Python - Tools/Utilities
- Python - Useful Resources
- Python - Discussion
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Python Number seed() Method
Description
Python number method seed() sets the integer starting value used in generating random numbers. Call this function before calling any other random module function.
Syntax
Following is the syntax for seed() method −
seed ( [x] )
Note − This function is not accessible directly, so we need to import the random module and then we need to call this function using random static object.
Parameters
x − This is the seed for the next random number. If omitted, then it takes system time to generate next random number.
Return Value
This method does not return any value.
Example
The following example shows the usage of seed() method.
#!/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()
When we run above program, it produces following result −
Random number with seed 10 : 0.57140259469 Random number with seed 10 : 0.57140259469 Random number with seed 10 : 0.57140259469
python_numbers.htm
Advertisements