Python Code Example: smallest and largest number in array

This program outputs the largest and smallest number from an array.

Code Explanation

LineDescription
1Declaration and initialization of the list myList with the values 4, 5, 3, 4, 1, 6 and 3.
3The min() method returns the smallest value of the list.
4The max() method returns the max value of the list.
myList = [4, 5, 3, 4, 1, 6, 3]

print(min(myList))
print(max(myList))
Output
1
6