内容
提示:这里可以添加本文要记录的大概内容:
if elif in and 布尔标记
提示:以下是本篇文章正文内容,下面案例可供参考
一.使用情况
1.elif
代码如下(示例):
country = input('please enter your country: ')
if country.lower() == 'china':
province = input('please enter your province: ')
if province.lower() in ('first','second','third'):
tax = 0.9
elif province.lower() == 'four':
tax = 0.5
else:
tax = 0
else:
tax = 0
print(tax)
2.if和布尔的使用情况
各有优缺点,注意使用前提不同,布尔大小写敏感
代码如下(示例):
ave_score = float(input('please enter your averange score: '))
lowest_score = float(input('please enter your lowest score: '))
if ave_score > 90 and lowest_score > 75:
Honor = True
else:
Honor = False
if Honor:
print('Good')