Exercise 12
By using the sort() method, write an algorithm in python as a function which takes a list L of numbers as a parameter and which returns the tuple (min , max) formed from the minimum and the maximum of the list.
Solution
|
1 2 3 4 5 6 7 8 |
def minMax(L): # sort the list L.sort() return (L[0] , L[-1]) # Example L = [37, 59, 11, 3, 47, 22 , 6] print(minMax(L)) # the output is: (3, 59) |
Younes Derfoufi
CRMEF OUJDA
Acheter sur Très Facile !
-

Obtenez Microsoft 365 Famille avec Office 365 apps - 15 Mois + NORTON 360 Deluxe - PC/MAC, tablette et smartphone
€ 57,00 Acheter le produit -

Routeur Intelligent Tenda AC6 WiFi sans Fil double Bande AC1200
€ 20,00 Acheter le produit -

Apprendre Raspberry Pi : Série pour les Nuls 2ème édition
€ 24,00 Acheter le livre
1 thought on “Solution Exercise 12: maximum and minimum of a Python list”