# Python Number uniform() Method

Advertisements

## 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

## Useful Video Courses

Video

#### Python Online Training

Most Popular

187 Lectures 17.5 hours

Video

#### Python Essentials Online Training

55 Lectures 8 hours

Video

#### Learn Python Programming in 100 Easy Steps

136 Lectures 11 hours

Video

#### Python with Data Science

75 Lectures 13 hours

Video

#### Python 3 from scratch to become a developer in demand

70 Lectures 8.5 hours

Video

#### Python Data Science basics with Numpy, Pandas and Matplotlib

63 Lectures 6 hours

Advertisements