Enter the height and weight and calculate BMI

Enter the height and weight and calculate BMI

BMI is calculated current programs height, weight is a fixed value, change the program to get input from the keyboard, and then calculate BMI.

First inputting the height (unit: m), and enter the weight (unit: kg), and then calculates and outputs a BMI.

In Python, may () instruction content acquired by the input keyboard input until it encounters the transport, the following code gets input and saved to the variable name:

# 请使用 input 获取键盘输入
height =float(input("输入体重:"))

# 请使用 input 获取键盘输入
weight = float(input("输入身高:"))

bmi = weight / (height ** 2)

print(bmi)
Published 74 original articles · won praise 25 · views 10000 +

Guess you like

Origin blog.csdn.net/qq_43191251/article/details/104803916