# -*- coding: utf-8 -*- height = 1.75 weight = 80.5
bmi = weight/height**2
if bmi<18.5:
print(体重过轻)
elif bmi<25:
print(体重正常)
elif bmi<28:
print(体重过重)
elif bmi<32:
print(肥胖)
else:
print(严重肥胖)
Traceback (most recent call last):
File "main.py", line 11, in <module>
NameError: name '体重过重' is not defined
哪里出现了问题呢?我想print一个字符串,为什么出现了错误呢?
print("体重过重")
要加上双引号,不然会被认为是个变量/常量之类的
Sign in to make a reply
FYin6326045216
bmi = weight/height**2
if bmi<18.5:
print(体重过轻)
elif bmi<25:
print(体重正常)
elif bmi<28:
print(体重过重)
elif bmi<32:
print(肥胖)
else:
print(严重肥胖)
Traceback (most recent call last):
File "main.py", line 11, in <module>
print(体重过重)
NameError: name '体重过重' is not defined
哪里出现了问题呢?我想print一个字符串,为什么出现了错误呢?