@ -2,6 +2,7 @@ import tkinter as tk
# Configuration de la fenêtre
screen = tk . Tk ( )
screen . title ( " Calcul de notes " )
screen . minsize ( 300 , 300 )
screen . maxsize ( 300 , 300 )
@ -9,14 +10,14 @@ lst_nombre = []
# Différents textes présents (ou non) sur la page
#Zone d'entrée pour les nombres
welcome_txt = tk . Label ( text = " Veuillez entrer des nombres, pour connaitre \n la note la plus basse, la plus haute et la moyenne ! " )
welcome_txt = tk . Label ( text = " Veuillez entrer des nombres, pour connaitre \n la note la plus basse, la plus haute et la moyenne ! \n Penser à bien vérifier vos nombre avant le calcul ! " )
welcome_txt . place ( relx = 0.5 , y = 70 , anchor = " center " )
zone_texte = tk . Entry ( width = 20 )
zone_texte . place ( relx = 0.5 , rely = 0.5 , anchor = " center " )
warning = tk . Label ( text = " " )
warning . place ( relx = 0.5 , rely = 0.3 , anchor = " center " )
warning . place ( relx = 0.5 , rely = 0.4 , anchor = " center " )
txt_note_min = tk . Label ( text = " " )
txt_note_min . place ( x = 0 , y = 10 )
@ -42,27 +43,37 @@ def Verif():
lst_nombre . append ( nombre )
warning . config ( text = " " )
except ValueError :
warning . config ( text = " Non " )
print ( " Dommage ! " )
warning . config ( text = " Invalide " )
# Calcule la note max, min et la moyenne
def Calcul ( ) :
global lst_nombre
total = 0
nombre_notes = 0
print ( lst_nombre )
lst_nombre . sort ( )
print ( lst_nombre )
note_min = lst_nombre [ 0 ]
note_max = lst_nombre [ - 1 ]
for i in range ( len ( lst_nombre ) ) :
total + = lst_nombre [ i ]
nombre_notes + = 1
moyenne = total / nombre_notes
moyenne = round ( moyenne , 1 )
txt_note_min . config ( text = f " Note la plus basse : { note_min } " )
txt_note_max . config ( text = f " Note la plus haute : { note_max } " )
txt_moyenne . config ( text = f " Moyenne du groupe : { moyenne } " )
try :
total = 0
nombre_notes = 0
print ( lst_nombre )
lst_nombre . sort ( )
print ( lst_nombre )
note_min = lst_nombre [ 0 ]
note_max = lst_nombre [ - 1 ]
for i in range ( len ( lst_nombre ) ) :
total + = lst_nombre [ i ]
nombre_notes + = 1
moyenne = total / nombre_notes
moyenne = round ( moyenne , 1 )
txt_note_min . config ( text = f " Note la plus basse : { note_min } " )
txt_note_max . config ( text = f " Note la plus haute : { note_max } " )
txt_moyenne . config ( text = f " Moyenne du groupe : { moyenne } " )
except IndexError :
txt_note_min . config ( text = " " )
txt_note_max . config ( text = " " )
txt_moyenne . config ( text = " " )
# Effacer les valeurs de la liste
def Effacer ( ) :
global lst_nombre
lst_nombre = [ ]
# Différents bouton qui renvoie aux deux fonctions
@ -72,4 +83,7 @@ bouton_verif.place(relx=0.5, rely=0.7, anchor="center")
bouton_calcul = tk . Button ( width = 8 , height = 3 , text = " Calcul " , command = Calcul )
bouton_calcul . place ( relx = 0.7 , rely = 0.8 , )
bouton_calcul = tk . Button ( width = 8 , height = 3 , text = " Effacer " , command = Effacer )
bouton_calcul . place ( x = 22 , rely = 0.8 , )
screen . mainloop ( )