Python maxint( )

Table of Contents What is the python max int() value function?Python max( ) value:Python min( ) valueSystem module:Python2:Python3 :Conclusion: What is the python max int() value function? The max int( ) function in python is …

Python maxint( )

What is the python max int() value function?

The max int( ) function in python is used to fetch the maximum or the largest value in the iterable.

These values are strings, alphabetic and numerical.

 To fetch the maximum integer value maxint( )

In python2 you can use the maxint() function to know the maximum or the largest value of integer datatype.

As in python2, there are two data types int and long.

But, In the latest python3 versions there is no concept of max int ( ).

Since it only contains the integer data type “int”

You can check the systems maximum size by using the systems module:

 sys.maxsize( )

Python max( ) value:

Python max( ) value function is used to fetch the maximum or largest value from the list or dictionary.

To check the maximum value, you can use the “max()” function:

Syntax:

max(n1, n2, n3…)

Let’s take an example to see how the max( ) function works :

Example:

#max int() value

a = [1, 4, 55, 7, 122, -999]
b = [12, 0.9909, 3432, 8989]
c = [3, 70.0, 8.348, 45.90, 349.89]
print(max(a))
print(max(b))
print(max(c))

In this example, 

First, we made lists and named them as a, b, & c.

Then, used the max() function inside the print statement to print the max value from the list.

Output:

122
8989
349.89
>

We can also use the max( ) function by using the syntax given below:

#max int() value
a = max (1, 4, 55, 7, 122, -999)
b = max (12, 0.9909, 3432, 8989)
c = max (3, 70.0, 8.348, 45.90, 349.89)
print(a)
print(b)
print(c)

In this example,

First, we define three lists and named as a, b, & c respectively.

And using the max()  function before the list.

That will show the maximum value from the list.

Then, used print function to display the output.

Output:

122
8989
349.89
>

Similarly, the way we checked the maximum value by using the max() function, we can also check the minimum value by using the min() function.

Before proceeding further, I would like to share an example of python minimum integer value:

Python min( ) value

Python min() value function is used to fetch the lowest value from the list.

Example:

#min int() value
a = min (900, 2034, 55.999, 8987, 122, -999)
b = min (1299, 89.09, 34932, 86689)
c = min (3, 70.0, 8.348, 45.90, 349.89)
print(a)
print(b)
print(c)

In this example, 

First, we defined three lists of integer values a, b, & c.

After that using the min() function and print the minimum value from the list.

Output:

-999
89.09
3
>

System module:

Python’s system module provides the collection of constants and functions.

Maxint() is one of those constants, used to fetch the largest positive integer value among all the integers.

To use the system module in python we will import the system module into the program

Import sys

Python2:

Maxint() is basically the function of python2

Where there is a limit for integer and after the maximum integer the datatype will change from integer to  long datatype.

#python maxint()
Import sys
sys.maxint

Output:

9223372036854775807

Let’s check the type of maxint( ) function in python2 interpreter:

Type(sys.maxint)
Type(sys.maxint+1 )

Output:

int
long 

Python3 :

In python3 there is no concept of maximum integer value and no boundary of the number of bits, but in python3 interpreter you can use system module to find out systems maximum size by using sysmaxsize( ).

import sys
sys.maxsize

To use the system module, first, we imported sys and used sys.maxsize This will give

Output:

9223372036854775807

To check the datatype by using type function:

type(sys.maxsize)

Output:

int

Conclusion:

In this article, we discussed the python maxint() function and along with it we also discussed python max(), python min() functions.

Suggested Read: Remove Brackets from list Python

Leave a Comment