aminmaxclass.py

Created by bilouclic

Created on December 15, 2024

479 Bytes


def min_max_classique(t : list) ->
tuple :
Cette fonction prend en paramètre un tableau et renvoie le couple composé du minimum et du maximum de ce tableau.
Elle effectue un simple parcours du tableau en conservant, à chaque itération, le minimum et maximum de la zone déjà parcourue.
if len(t) == 0 : return None
i_min, i_max = 0, 0
for i in range(1, len(t)):
if t[i] < t[i_min] : i_min = i
elif t[i] > t[i_max] : i_max = i
return t[i_min], t[i_max]


During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.