Home » Find Largest and Smallest Item in a Tuple in python

Find Largest and Smallest Item in a Tuple in python

Oracle Java Certification
Java SE 11 Programmer I [1Z0-815] Practice Tests
Spring Framework Basics Video Course
1 Year Subscription
Java SE 11 Developer (Upgrade) [1Z0-817]
Java SE 11 Programmer II [1Z0-816] Practice Tests

In this example we use the min and max functions which will return the smallest and largest items ina  tuple

Example

# Largest and Smallest Item in a tuple
number_tuple = (12, 47, 44, 9, 74, 68, 21, 32, 53, 19)
print("Tuple Items = ", number_tuple)

print("Largest  Item in the Tuple is ", max(number_tuple))
print("Smallest Item in the Tuple is ", min(number_tuple))

When you run this you will see something like this

>>> %Run maxmintuple.py
Tuple Items =  (12, 47, 44, 9, 74, 68, 21, 32, 53, 19)
Largest  Item in the Tuple is  74
Smallest Item in the Tuple is  9

You may also like

Leave a Comment

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More