# Write a Program to Find the largest of n numbers,
# using a user defined function largest()
# First we declare a Function
# name should be largest()
def largest(list1): # its take a list
top = list1[0]
for a in list1:
if a > top:
top = a
return top
# Call the Function
# take a blank list
li = []
# input the size of list
num = int(input("How Many Elements in the List"))
for i in range(num):
number = int(input("Enter the Element "))
li.append(number)
# Print the Largest Value
print("Largest Element in the List is:", largest(li))
Output:
How Many Elements in the List3
Enter the Element 56
Enter the Element 12
Enter the Element -47
Largest Element in the List is: 56