Python standard library: built-in functions min (iterable, * [, key, default]), pythoniterable

Source: Internet
Author: User

Python standard library: built-in functions min (iterable, * [, key, default]), pythoniterable

Min (arg1, arg2, * args [, key])

This function compares the iteration object iterable to find the minimum value and return it. When the key parameter is not null, the function object of the key is used as the criterion for determination.

Example:

# Min () array1 = range (10) array2 = range (0, 20, 3) print ('min (array1) = ', min (array1 )) print ('min (array2) = ', min (array2) print ('min (array1,) =', min (array1, key = lambda x: x <3 )) print (min (1, 2) print (min ('Ah', 'bf', key = lambda x: x [1]) print (min (array1, array2, key = lambda x: x [1]) def comparator (x): return x [2] print (min ('ah2', 'bf3', key = comparator ))

The output is as follows:

Min (array1) = 0

Min (array2) = 0

Min (array1,) = 3

1

Bf

Range (0, 10)

Ah2

 

 

Cai junsheng QQ: 9073204 Shenzhen

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.