Discuss / Python / bim = int(b) 这个行代码意义何在???

bim = int(b) 这个行代码意义何在???

Topic source

LarnEMzer

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

bim = int(b) 这个行代码意义何在??? 没有这行代码,也运行的起来的 还有int()是整数的,“1.75”输入进去会显示错误的。

在此插入代码

s = input('enter your height:') height = int(s) t = input('enter your weight:') weight = int(t) bim = weight/height**2

if bim>=32: print('严重肥胖') elif bim>=28: print('肥胖') elif bim>=25: print('过重') elif bim>=18.5: print('正常') else: print('过轻')

``` 在此插入代码

```# -- coding: utf-8 -- s = input('enter your height:') height = int(s) t = input('enter your weight:') weight = int(t) b = weight/height**2 bim = int(b) if bim>=32: print('严重肥胖') elif bim>=28: print('肥胖') elif bim>=25: print('过重') elif bim>=18.5: print('正常') else: print('过轻')

IE之梦

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

这一行就是把你输入的值转为int型 是整数 1.75是浮点数应该用float


  • 1

Reply