05条件分支

'''
if

'''
a=1
b=2
if a==b:
print(a)
print(b)

'''
与C语言不同,python语言的if格式必须为if 布尔表达式:(冒号不能省略)
其二,python有严格的缩进格式,同一缩进格式表示为同一模块
if控制的语句为缩进格数相同的所有语句
'''

'''
if-else
'''
a=1
b=2
if a>b:
print(a)
else:
print(b)

'''
if-elif-else
'''
score=95
if score>=90:
print('A')
elif score>=70:
print('B')
else:
print('C')

'''
学习Python过程中,是没有switch-case控制语句的
'''

猜你喜欢

转载自www.cnblogs.com/wsxcode/p/12198417.html
今日推荐