Write python program To display the sum of largest and smallest value of a two-dimension array.
numbers2D = [[11, 12, 5, 2], [15,18 ,6,10], [10, 8, 12, 5], [12,15,8,6]]
for row in numbers2D:
for column in row:
print(column,end = "\t")
print()
largestValue=max(max(x) for x in numbers2D)
smallestValue=min(min(x) for x in numbers2D)
sumLargestSmallest=largestValue+smallestValue
print(f"\nThe largest value: {largestValue}")
print(f"The smallest value: {smallestValue}")
print(f"The sum of largest and smallest value of a two-dimension array: {sumLargestSmallest}")
Comments
Leave a comment