Introduction to using the Max () method to find the maximum value in Python

Source: Internet
Author: User
The max () method returns the maximum value of its parameter: the value closest to the positive infinity.
Grammar

The following is the syntax for the Max () method:

Max (x, y, Z, ...)

Parameters

  • X--This is a numeric expression.
  • Y-This is also a numeric expression.
  • Z--This is a numeric expression.

return value

This method returns the maximum value of its parameter.
Example

The following example shows the use of the Max () method.

#!/usr/bin/pythonprint "Max (+, +):", Max (+, +) print "Max ( -20, +):", Max ( -20, +) print " Max ( -80, -20, -10): ", Max ( -80, -20, -10) print" max (0, +, -400): ", max (0, 100,-400)

When we run the above program, it produces the following results:

Max (1000max, -20, +): 400max ( -80, -20, -10): -10max (0, 100,-400): 100
  • 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.