Home >Backend Development >Python Tutorial >What is random library python

What is random library python

silencement
silencementOriginal
2019-05-17 13:14:546943browse

The random module in Python is used to generate random numbers from various distributions. The random module can generate random floating point numbers, integers, strings, and even help you randomly select an element in a list sequence, scramble a set of data, etc.

What is random library python

The most commonly used functions are as follows:

Before using the random function, you must first call it, import random

1, random.random(), generates a random integer between 0 and 1

What is random library python

2, random.randint(1,10), generates Random integers between 1 and 10

What is random library python

##3,

random.randange(1,100,2), generates 1~100 Integers separated by 2

What is random library python

The above is the detailed content of What is random library python. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn