python program to find lowest and greatest number from the 10 number
Answers
Answered by
4
Task :
To find largest and smallest number in a list.
Approach :
Read input number asking for length of the list using input() or raw_input().
Initialise an empty list lst = [].
Read each number using a for loop.
In the for loop append each number to the list.
Now we use predefined function max() to find the largest element in a list.
Similarly we use another predefined function min() to find the smallest element in a list.
Program:
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), "\nMinimum element in the list is :", min(lst))
Attachments:
Similar questions