Discuss / Python / 提交作业，

### 提交作业，

Topic source

#### PG丶乌鸦

#1 Created at ... [Delete] [Delete and Lock User]

height = input('请输入你的身高:(米) ') weight = input('请输入你的体重：(公斤)') s1 = float(height) s2 = float(weight) bmi = s2 / (s1 * s1) print('身高: %f 米,体重: %d 公斤,BMI:%d' %(s1,s2,bmi)) if bmi <= 18.5: print('过瘦') elif bmi <= 25: print('正常体重') elif bmi <= 28: print('有点小重') elif bmi <= 32: print('肥了') else: print('大胖子')

1.800000 米 小数点那么多，应该怎么去掉呢， 用%d的话，又直接变1米了。。

#### II0w0II

#2 Created at ... [Delete] [Delete and Lock User]

print('身高: %f 米,体重: %d 公斤,BMI:%d' %(s1,s2,bmi)) 这一行，把%f改成%.2f即可

#### PG丶乌鸦

#3 Created at ... [Delete] [Delete and Lock User]

#### 我就爱钱123

#4 Created at ... [Delete] [Delete and Lock User]

def bmi(w,h): bmi=w/(h*h/10000) if w<18.5: print("过轻") elif 18.5<=bmi<=25: print("正常") elif 25<bmi<=28: print("过重") elif 28<bmi<=32: print("肥胖") else: print("严重肥胖")

w=int(input("请输入体重：（KG）")) h=int(input("请输入身高：（CM）"))

bmi(w,h)

#### DefconGroup0531

#5 Created at ... [Delete] [Delete and Lock User]

print('身高: %f 米,体重: %d 公斤,BMI:%d' %(s1,s2,bmi)) 这一行，把%f改成%s也可以

• 1