Python Program to Find Largest of n Numbers

Python program to find largest of n numbers; Through this tutorial, i am going to show you how to find the largest or maximum number of n numbers in python.

Python Program to Find Largest or Maximum of n Numbers

See the following python program to find the largest or maximum number of n number in python; as shown below:

  • 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

See the following python program to find largest number from list of n numbers using max; as shown below:

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 of the above program is:

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

See the python program to find largest or maximum of n numbers without max; as shown below:

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 of the above program is:

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

Recommended Python Tutorials

Leave a Comment