What is random library python

silencement
Release: 2019-05-22 13:51:16
Original
6905 people have browsed it

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template