#Exercise 3 - Find the largest and smallest number in a list
thislist = input("How many numbers do you want to enter:")
newlist = []
for x in range (0, int(thislist)):
owl = int(input("Please Enter your numbers:"))
newlist.append(owl)
print ("The max number entered is:", max(newlist))
print ("The min number entered is:", min(newlist))
thislist = [677,8765,8765,876,470,754,6784,56789,7658,]
thislist.sort()
print ("The smallest number is: " + str(thislist[0]))
print ("The largest number is: " + str(thislist[-1]))
# Python program to find smallest
# number in a list
# creating empty list
list1 = []
# asking number of elements to put in list
num = int(input("Enter number of elements in list: "))
# iterating till num to append elements in list
for i in range(1, num + 1):
ele= int(input("Enter elements: "))
list1.append(ele)
# print maximum element
print("Smallest element is:", min(list1))
Python | Largest, Smallest, Second Largest, Second Smallest in a List
# Python prog to illustrate the following in a list
def find_len(list1):
length = len(list1)
list1.sort()
print("Largest element is:", list1[length-1])
print("Smallest element is:", list1[0])
print("Second Largest element is:", list1[length-2])
print("Second Smallest element is:", list1[1])
# Driver Code
list1=[12, 45, 2, 41, 31, 10, 8, 6, 4]
Largest = find_len(list1)
# Python program to find smallest
# number in a list
# list of numbers
list1 = [10, 20, 4, 45, 99]
# sorting the list
list1.sort()
# printing the first element
print("Smallest element is:", *list1[:1])