Python standard library: Built-in function min (iterable, *[, key, default])

Source: Internet
Author: User
Tags iterable

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

This function is the iteration object iterable to compare, find the minimum value to return. When the key parameter is not empty, it is judged by the function object of key.

Example:

#min () Array1 = Range (Ten) Array2 = Range (0, 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]) prin T (min (array1, array2, Key=lambda x:x[1]) def comparator (x):   return X[2]print (min (' ah2 ', ' bf3 ', Key=comparator))

The resulting output is as follows:

Min (array1) = 0

Min (array2) = 0

Min (array1,) = 3

1

Bf

Range (0, 10)

Ah2

Cai Junsheng qq:9073204 Shenzhen

Python standard library: Built-in function min (iterable, *[, key, default])

Related Article

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.