calculadoraIMC / app.py
Edgaaar1's picture
Create app.py
3eb1e8b
raw
history blame contribute delete
764 Bytes
import gradio as gr
def imc(alçada, pes):
imc = float (pes) / float(alçada)**2
imc = round(imc, 2)
text =""
if imc<18:
text = "Magror"
elif imc <25 and imc <30:
text = "Corpulència normal"
elif imc < 30 and imc <40:
text = "Obesitat"
else:
text = "Obesitat mòrbida"
return imc, text
with gr.Blocks() as demo:
gr.Markdown ("CALCULADORA IMC")
with gr.Row():
alçada = gr.Textbox(label="Alçada (m)")
pes = gr.Textbox(label="Pes (kg)")
imc_btn = gr.Button("Calcula", size = "sm")
with gr.Row():
sortida = gr.Textbox(label="IMC")
sortida_text = gr.Textbox()
imc_btn.click(fn=imc, inputs= [alçada,pes], outputs = [sortida, sortida_text])
demo.launch(debug=True)