Saturday, January 17, 2026
HomeLanguagesPython nmaxmin Module

Python nmaxmin Module

A nmaxmin module is that library of Python which helps you to find the nth maximum number and nth minimum number in a given list. It directly returns either the maximum number or minimum number with respect to the given index (n). Here the given list must not be in sorted order as it will traverse the list itself.

Note: Here’n’ must lies between ‘1’ and length of list, otherwise it will throw an exception .

Installing Library

This module does not come built-in with Python. You need to install it externally. To install this module type the below command in the terminal.

pip install nmaxmin 

Functions of nmaxmin

  • nmaxmin.maxn(l, n): This function takes two parameters as input (one is a list and the second is index ‘n’).It will return the nth maximum number from the list as output.

    Example :




    # Importing maxn function  
    # From nmaxmin Library  
       
    from nmaxmin import nmaxmin
      
    l =[10, 25, 40, 30, 15, 50, 65, 70]
      
    a = nmaxmin.maxn(l, 3)
    print("The 2nd maximum number in a list l is ", a) 
        
    a = nmaxmin.maxn(l, 5)
    print("The 5th maximum number in a list l is ", a) 
      
    a = nmaxmin.maxn(l, 8)
    print("The 8th maximum number in a list l is ", a)

    
    

    Output:

    The 2nd maximum number in a list l is  50
    The 5th maximum number in a list l is  30
    The 8th maximum number in a list l is  10
    # Importing minn function  
    
  • nmaxmin.minn(l, n): This function takes two parameters as input (one is a list and the second is index ‘n’).It will return the nth minimum number from the list as output.

    Example :




    # Importing minn function  
    # From nmaxmin Library  
       
    from nmaxmin import nmaxmin
      
    l =[10, 25, 40, 30, 15, 50, 65, 70]
      
    a = nmaxmin.minn(l, 5)
    print("The 5th minimum number in a list l is ", a) 
      
    a = nmaxmin.minn(l, 2)
    print("The 2nd minimum number in a list l is ", a) 
        
    a = nmaxmin.minn(l, 1)
    print("The 1st minimum number in a list l is ", a) 

    
    

    Output:

    The 5th minimum number in a list l is  40
    The 2nd minimum number in a list l is  15
    The 1st minimum number in a list l is  10
    
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32474 POSTS0 COMMENTS
Milvus
118 POSTS0 COMMENTS
Nango Kala
6846 POSTS0 COMMENTS
Nicole Veronica
11977 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12062 POSTS0 COMMENTS
Shaida Kate Naidoo
6985 POSTS0 COMMENTS
Ted Musemwa
7219 POSTS0 COMMENTS
Thapelo Manthata
6933 POSTS0 COMMENTS
Umr Jansen
6911 POSTS0 COMMENTS