Python Program to Find Largest of n Number in a list

20-Oct-2022

.

Admin

Python Program to Find Largest of n Number in a list

Hi Dev,

In this short tutorial we will cover an Python Program to Find Largest of n Number in a list. I’m going to show you about Largest among N numbers. you will learn Python: Get the largest number from a list. let’s discuss about write a python program to print the largest of n numbers. So, let's follow few step to create example of Maximum N numbers in Python.

The objective of this Python post, you will see various Python programs that cover the following:

let's see below simple example with output:

Example 1: Python program to find largest of n numbers using max


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 8

Enter number 13

Enter number 18

Enter number 21

Enter number 5

Maximum element in the list is : 21

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

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 5

Enter number 9

Enter number 4

Maximum element in the list is : 9

I hope it can help you...

#Python