# random() module in Python

In this tutorial, we are going to see how to use the random module in Python.

A random module is generally used to generate Pseudo-random numbers. The pseudo-random numbers are generated by some deterministic computation.

1. random( )
2. randint( )
3. randrange( )
4. choice( )
5. shuffle( )

## different random() function in Python

There are various functions are used to generate these random numbers. let’s see it one by one.

To use a random module from Python first we need to import it from the Python library.

`import random`

## .random()

This random.random( ) function is used to generate the float  numbers between 0.0 to 1.0.

```>>> import random
>>> random.random()
0.930526309688996```

The arguments are not needed in it.

## .randint()

This random.randint( ) function which returns the random value from the given range.

consider the below example,

```>>> import random
>>> random.randint(1,50)
20```

here, inside the parameter we passed 1 as a start value and 50 as given as end value.so it will return a random number between the range 1 and 50.

Note: it will also return the start or end number also. ie.,1 or 50 as a random number.

## .randrange()

This random.randrange( ) function will return a value that is given inside the range sequence.

```>>> import random
>>> random.randrange(1,20,2)
17
```

Inside the range function, we were given the start value is 1, the end value is 10  and the step value is given 2 so it will generate any random numbers between 1 and 20  inside with step value 2.

## .choice()

The random.choice( ) will return a random number from the given sequence of numbers.

```>>> import random
>>> random.choice((10,11,12,14,15,16))
12```

Here the sequence of numbers was given inside the choice. So, it will return a number from it.

## .shuffle()

The random.shuffle( )  will randomly shuffle the elements present inside the list.

```>>> import random
>>> value = [10,11,12,13,14,15]
>>> random.shuffle(value)
>>> value
[13, 14, 15, 10, 12, 11]```
{"ft_lang_label":"__label__en","ft_lang_prob":0.70118433,"math_prob":0.99549055,"size":1994,"snap":"2019-43-2019-47","text_gpt3_token_len":485,"char_repetition_ratio":0.18040201,"word_repetition_ratio":0.006042296,"special_character_ratio":0.29137412,"punctuation_ratio":0.16176471,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99744964,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-11-21T14:07:36Z\",\"WARC-Record-ID\":\"<urn:uuid:b65bbd10-2377-46ce-98b4-9d4f0f8a5814>\",\"Content-Length\":\"31391\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:2792f46e-4dfe-4fdc-8385-b4f178f91a32>\",\"WARC-Concurrent-To\":\"<urn:uuid:90e60287-a580-4d1b-8951-20ace14af039>\",\"WARC-IP-Address\":\"104.27.179.5\",\"WARC-Target-URI\":\"https://www.codespeedy.com/random-module-in-python/\",\"WARC-Payload-Digest\":\"sha1:NUJHCGB4WC5QQYHPCQW3S6YH6TR4JV26\",\"WARC-Block-Digest\":\"sha1:S5TI23DJ44ZJFHOZPBILXDXAJLNPFYBF\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-47/CC-MAIN-2019-47_segments_1573496670821.55_warc_CC-MAIN-20191121125509-20191121153509-00456.warc.gz\"}"}