Rrandom module randomly generates numbers

Source: Internet
Author: User

Random.random () generates a floating-point number from 0 to 1, excluding 0 excluding 1
Random.uniform (100,1000) specifies that a floating-point number be returned with a maximum minimum value
Random.randint (1,3) random integer application within the specified range: SMS Verification Code
Random.choice ([1,34,5,6,6]) getting random elements from a sequence
Random.randrange (10,100,2) gets a random integer from the list by a collection that increments by the specified technique

>>> Import Random
>>> random.randrange (0, 101, 2)
42
Random.shuffle (p) is used to disrupt elements in the list
Random.sample (list,4) randomly acquires a length fragment from the specified, and the sample function does not modify the list's sequence

>>> Import Random
Random.sample (' Abcdefghij ', 3)
The three numbers taken out of [' a ', ' d ', ' B '] are also unordered

Rrandom module randomly generates numbers

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.