-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathejercicio_09.py
More file actions
30 lines (22 loc) · 1.21 KB
/
ejercicio_09.py
File metadata and controls
30 lines (22 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# Escribir un programa que pida al usuario su peso (en kg) y estatura (en metros), calcule el índice de masa corporal y lo almacene en una variable, y muestre por pantalla la frase Tu índice de masa corporal es <imc> donde <imc> es el índice de masa corporal calculado redondeado con dos decimales. El usuario podrá poner el peso y la altura con . o con , en los decimales
height = input("Dime tu altura en metros, por ejemplo 1.7: ")
height = height.replace(',', '.')
clean_height = height.replace('.', '')
while(clean_height.isnumeric() == False):
print("No has introducido un valor correcto. Vuelve a intentarlo: ")
height = input("Dime tu altura en metros: ")
height = height.replace(',', '.')
clean_height = height.replace('.', '')
height = float(height)
weight = input("Dime tu peso en kg: ")
weight = weight.replace(',', '.')
clean_weight = weight.replace('.', '')
while(clean_weight.isnumeric() == False):
print("No has introducido un valor correcto. Vuelve a intentarlo: ")
weight = input("Dime tu peso en kg: ")
weight = weight.replace(',', '.')
clean_weight = weight.replace('.', '')
weight = float(weight)
imc = weight/height**2
imc = round(imc, 2)
print("Tu IMC es: " + str(imc))