Input a list of numbers and find the smallest and largest number from the list.

numbers=[3,6,7,8,4,10,1]
size=len(numbers)
i=0
max=0
while(i<size):
   if(numbers[i]>max):
       max=numbers[i]
       i=i+1
i=1
min=numbers[0]
while(i<size):
    if(numbers[i]<min):
       min=numbers[i]
       i=i+1
print('largest number is ',max)
print('smallest number is ',min)
 
Explanation: In this program we have taken a list of numbers named numbers, then we took number of elements in the list using len function. initialized counter variable i to 0 and max number variable to 0. program enters while loop and compares all numbers in list with max variable.
 
whenever a number greater than  max variable value comes, max variable is updated with that number value. this way max variable has highest value at the end of the loop.
 
Same thing is repeated to find minimum value in the list, the only difference is here we are using less than operator instead of using greater than operator as in above case.