How to know Maximum and Minimum values for ints in Python?

Python's core library provides built-in functions max() and min() to find maximum and minimum values from sequences like lists, tuples, or multiple arguments. Additionally, Python offers ways to discover the system limits for integer values.

Using max() and min() Functions

With Multiple Arguments

You can pass multiple numbers directly to max() and min() ?

print(max(23, 21, 45, 43))
print(min(23, 21, 45, 43))
45
21

With Lists and Tuples

These functions also work with sequence objects like lists and tuples ?

numbers_list = [20, 50, 40, 30]
numbers_tuple = (30, 50, 20, 40)

print("List max:", max(numbers_list))
print("List min:", min(numbers_list))
print("Tuple max:", max(numbers_tuple))
print("Tuple min:", min(numbers_tuple))
List max: 50
List min: 20
Tuple max: 50
Tuple min: 20

Integer Limits in Python

Python 3 has unlimited precision integers, but you can still check system limits using the sys module ?

import sys

print("Maximum int size info:", sys.int_info)
print("Maximum float value:", sys.float_info.max)
print("Minimum float value:", sys.float_info.min)
Maximum int size info: sys.int_info(bits_per_digit=30, sizeof_digit=4, default_max_str_digits=4300, str_digits_check_threshold=640)
Maximum float value: 1.7976931348623157e+308
Minimum float value: 2.2250738585072014e-308

Comparison

Function Purpose Input Types
max() Find maximum value Multiple args, lists, tuples
min() Find minimum value Multiple args, lists, tuples
sys.int_info Integer implementation details System information

Conclusion

Use max() and min() to find extreme values in sequences or multiple arguments. Python 3 integers have unlimited precision, but sys.int_info provides implementation details for system limits.

Updated on: 2026-03-24T20:14:49+05:30

188 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements