note-calc / app.py
Docfile's picture
Update app.py
bd2b028 verified
raw
history blame contribute delete
No virus
4.29 kB
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 1 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,eps
):
math = math * 5
francais = francais * 3
physique = physique * 4
svt = svt * 3
philo = philo * 2
documentation = documentation * 1
thea = thea * 3
anglais = anglais * 2
hist = hist * 3
espagnol = espagnol * 2
eps = eps * 2
conduite = 14 * 1
# Collectez les données des matières dans un tableau
data = [
["Math", math/5],
["Français", francais/3],
["Physique", physique/4],
["SVT", svt/3],
["Philo", philo/2],
["Documentation", documentation/1],
["Théâtre", thea/3],
["Histoire", hist/3],
["Anglais", anglais/2],
["Espagnol", espagnol/2],
["Eps",eps/2],
["Conduite", conduite/1],
]
# 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
+ eps
+ conduite
)
r = total / 31
print(f"Moyenne : {matha.trunc(r * 100) / 100}")
return matha.trunc(r * 100) / 100
def calcul_td(
math, francais, physique, svt, philo, thea, anglais, hist, espagnol
):
math = math * 4
francais = francais * 3
physique = physique * 4
svt = svt * 4
philo = philo * 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/4],
["Français", francais/3],
["Physique", physique/4],
["SVT", svt/4],
["Philo", philo/2],
["Théâtre", thea/3],
["Histoire", hist/3],
["Anglais", anglais/2],
["Espagnol", espagnol/2],
]
# 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
+ thea
+ hist
+ anglais
+ espagnol
)
r = total / 27
print(f"Moyenne : {matha.trunc(r * 100) / 100}")
return matha.trunc(r * 100) / 100
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"),
gr.Number(label="Eps")
],
outputs=gr.Textbox(label="Moyenne"),
description=description_c,
)
app2 = gr.Interface(
fn=calcul_td,
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="Théâtre"),
gr.Number(label="Histoire"),
gr.Number(label="Anglais"),
gr.Number(label="Espagnol"),
],
outputs=gr.Textbox(),
description=description_r,
)
demo = gr.TabbedInterface([app1, app2], ["Calcule-1ere S2 ", "Terminal A1"])
demo.launch()