import math as matha import gradio as gr from tabulate import tabulate # Importez la bibliothèque tabulate title_c = "Calculateur de moyenne !" description_c = """Entrez vos notes pour chaque matière pour calculer votre moyenne. Note : les coefficients de cette app sont adaptés à la classe de première S uniquement. Je ferais une mise à jour plus tard si j'ai le temps. la conduite est fixée à 14/20. Et ici la virgule s'écrit avec le point. Exemple : 12,5 devient 12.5 Juste la moyenne trimestrielle ohhhh pas plus. en tout cas......... J'ai mis documentation 2 de coef """ description_r = """ En cours.... mais en vérité tout dépendra de mon humeur........ """ def calcul( math, francais, physique, svt, philo, documentation, thea, anglais, hist, espagnol ): math = math * 5 francais = francais * 3 physique = physique * 4 svt = svt * 3 philo = philo * 2 documentation = documentation * 2 thea = thea * 3 anglais = anglais * 2 hist = hist * 3 espagnol = espagnol * 2 conduite = 14 * 1 # Collectez les données des matières dans un tableau data = [ ["Math", math], ["Français", francais], ["Physique", physique], ["SVT", svt], ["Philo", philo], ["Documentation", documentation], ["Théâtre", thea], ["Histoire", hist], ["Anglais", anglais], ["Espagnol", espagnol], ["Conduite", conduite], ] # Affichez le tableau dans la console print("Données des matières :") print(tabulate(data, headers=["Matière", "Note"], tablefmt="fancy_grid")) print() # Ligne vide pour la clarté total = ( math + francais + physique + svt + philo + documentation + thea + hist + anglais + espagnol + conduite ) r = total / 30 print(f"Moyenne : {matha.trunc(r * 100) / 100}") return matha.trunc(r * 100) / 100 def cr(t): print(f"ho: {t}") return " ah.... " app1 = gr.Interface( fn=calcul, inputs=[ gr.Number(label="Math"), gr.Number(label="Français"), gr.Number(label="Physique"), gr.Number(label="SVT"), gr.Number(label="Philo"), gr.Number(label="Documentaion"), gr.Number(label="Théâtre"), gr.Number(label="Histoire"), gr.Number(label="Anglais"), gr.Number(label="Espagnol"), ], outputs=gr.Textbox(label="Moyenne"), description=description_c, ) app2 = gr.Interface( fn=cr, inputs=gr.Textbox(), outputs=gr.Textbox(), description=description_r, ) demo = gr.TabbedInterface([app1, app2], ["Calcule-1ere S2 ", "Terminal A1"]) demo.launch()