
- 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 uniform() Method
Description
Python number method uniform() returns a random float r, such that x is less than or equal to r and r is less than y.
Syntax
Following is the syntax for uniform() method −
uniform(x, y)
Note − This function is not accessible directly, so we need to import uniform module and then we need to call this function using random static object.
Parameters
x − Sets the lower limit of the random float.
y − Sets the upper limit of the random float.
Return Value
This method returns a floating point number.
Example
The following example shows the usage of uniform() method.
#!/usr/bin/python import random print "Random Float uniform(5, 10) : ", random.uniform(5, 10) print "Random Float uniform(7, 14) : ", random.uniform(7, 14)
Let us run the above program, this will produce the following result −
Random Float uniform(5, 10) : 5.52615217015 Random Float uniform(7, 14) : 12.5326369199
python_numbers.htm
Advertisements