Friday, September 5, 2025
HomeLanguagesPython Program to Find Largest/Maximum of n Numbers

Python Program to Find Largest/Maximum of n Numbers

Find largest/maximum number of n numbers in Python; In this tutorial, you will learn how to find largest/max number from n numbers in python.

Python Program to Find Largest/Maximum of n Numbers

  • Python program to find largest of n numbers using max
  • Python program to find largest of n numbers without using built-in function

Python program to find largest of n numbers using max

  • Take input number for the length of the list using python input() function.
  • Initialize an empty list lst = [].
  • Read each number in your python program using a for loop.
  • In the for loop append each number to the list.
  • Use built-in python function max() to find the largest element in a list.
  • End of the program print the largest number from list.
lst = []

num = int(input('How many numbers: '))

for n in range(num):
    numbers = int(input('Enter number '))
    lst.append(numbers)
    
print("Maximum element in the list is :", max(lst))

Output

How many numbers:  5
Enter number  4
Enter number  6
Enter number  8
Enter number  9
Enter number  10
Maximum element in the list is : 10

Python program to find largest of n numbers without using built-in function

  • Take input number for the length of the list using python input() function.
  • Initialize an empty list lst = [].
  • Read each number in your python program using a for loop.
  • In the for loop append each number to the list.
  • Define a custom function, which is an accepted number list and used to find the largest number from list.
  • Call this custom function and store the function result.
  • End of the program print the largest number from list.
def find_max( list ):
    max = list[ 0 ]
    for a in list:
        if a > max:
            max = a
    return max


num = int(input('How many numbers: '))

lst = []

for n in range(num):
    numbers = int(input('Enter number '))
    lst.append(numbers)
    
print("Maximum element in the list is :", find_max(lst))

Output

How many numbers:  3
Enter number  1
Enter number  5
Enter number  7
Maximum element in the list is : 7

Recommended Python Programs

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32264 POSTS0 COMMENTS
Milvus
81 POSTS0 COMMENTS
Nango Kala
6634 POSTS0 COMMENTS
Nicole Veronica
11801 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11863 POSTS0 COMMENTS
Shaida Kate Naidoo
6750 POSTS0 COMMENTS
Ted Musemwa
7025 POSTS0 COMMENTS
Thapelo Manthata
6701 POSTS0 COMMENTS
Umr Jansen
6718 POSTS0 COMMENTS