+ 3

guys what's the way to solve the IMC calculator in Python beginners? Hidden test 4 fails, Take a look at my code: help!!

#this is the code I've wrote... def _imc(): p=float(input()) a=float(input()) r = p/(a**2) if r < 18.5: m= "Underweight" print (m) elif r >=18.5 and r <= 24.9: m= "Normal" print (m) elif r >= 25 and r <= 29.9: m= "Overweight" print (m) elif r >= 30: m= "Obesity" print (m) _imc() #thanks in advance to all who could help me solve this one...

28th May 2021, 11:09 PM
Juan Bohórquez
Juan Bohórquez - avatar
8 Réponses
+ 4
A mi me falla en la prueba 4 y no sé el motivo. #tu código va aquí peso = float(input()) altura = float(input()) imc = peso / (altura ** 2) if imc < 18.5: print("Underweight") elif imc >= 18.5 and imc <= 24.9: print("Normal") elif imc >= 25 and imc <= 29.9: print("Overweight") elif imc >= 30: print("Obesity")
26th Aug 2021, 12:56 AM
taisedekar
taisedekar - avatar
+ 4
Jaja ok gracias, me funcionó
26th Aug 2021, 12:16 PM
taisedekar
taisedekar - avatar
+ 3
De nada
14th Oct 2021, 1:34 PM
CGO!
CGO! - avatar
+ 2
Que significa, round a los float?
22nd Sep 2021, 5:15 AM
Pincho Jvnil
+ 2
Pincho Jvnil Significado de float: Flotante Ahora round es redondear el número de lugares del float es el segundo parámetro, el primero es el número, si no pones un segundo número te deja el número entero, sin decimal, por ejemplo: print(round(80.0861846)) print(round(80.16, 1)) Salida: 80 80.1
13th Oct 2021, 6:44 PM
CGO!
CGO! - avatar
+ 1
Amigo, le das round en los float
26th Aug 2021, 1:26 AM
Juan Bohórquez
Juan Bohórquez - avatar
+ 1
Genial! Gracias!
14th Oct 2021, 1:03 PM
Pincho Jvnil
0
Already solved! The trick is to keep sure not to let float to be a mess
29th May 2021, 1:45 AM
Juan Bohórquez
Juan Bohórquez - avatar