Ajout du tp sur python
This commit is contained in:
29
sisr2/sisr/35-python/tableau.py
Normal file
29
sisr2/sisr/35-python/tableau.py
Normal file
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
tab = []
|
||||
|
||||
for i in range (0, 4):
|
||||
valeur = int(input("Saisir un nombre à inclure dans le tableau :"))
|
||||
tab.append(valeur)
|
||||
|
||||
min = tab[0]
|
||||
max = tab[0]
|
||||
somme = 0
|
||||
|
||||
for elem in tab:
|
||||
if elem < min:
|
||||
min = elem
|
||||
if elem > max:
|
||||
max = elem
|
||||
somme += elem
|
||||
|
||||
print("Le plus petit élément du tableau est de :",min)
|
||||
print("Le plus grand élément du tableau est de :",max)
|
||||
|
||||
moyenne = somme /len(tab)
|
||||
|
||||
print("La moyenne du tazbleau est : ",moyenne)
|
||||
|
||||
print("Affichage du tableau :")
|
||||
for i in tab:
|
||||
print("Element ", i )
|
||||
Reference in New Issue
Block a user