28.10.2021 Views

Python Tutorial ( PDFDrive )

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Return Value

This method returns the elements from the tuple with maximum value.

Example

The following example shows the usage of max() method.

#!/usr/bin/python

tuple1, tuple2 = (123, 'xyz', 'zara', 'abc'), (456, 700, 200)

print "Max value element : ", max(tuple1);

print "Max value element : ", max(tuple2);

Let us compile and run the above program, this will produce the following result:

Max value element : zara

Max value element : 700

min(tuple)

Description

The method min() returns the elements from the tuple with minimum value.

Syntax

Following is the syntax for min() method:

min(tuple)

Parameters

• tuple -- This is a tuple from which min valued element to be returned.

Return Value

This method returns the elements from the tuple with minimum value.

Example

The following example shows the usage of min() method.

#!/usr/bin/python

tuple1, tuple2 = (123, 'xyz', 'zara', 'abc'), (456, 700, 200)

print "min value element : ", min(tuple1);

print "min value element : ", min(tuple2);

Let us compile and run the above program, this will produce the following result:

min value element : 123

TUTORIALS POINT

Simply Easy Learning

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!