单分支结构:
money = 1000
a = int(input("请输入取款金额:"))
#选择结构
if money>=a:
money=money-a
print("取款成功 余额是:",money)
--------------------没有判断溢出的情况
双分支结构
money = 1000 a = int(input("请输入取款金额:")) #选择结构 if money>=a: money=money-a print("取款成功 余额是:",money) else: print("超过取款金额")
多分支结构
'''
实现成绩的判断
'''
a=int(input('输入成绩:'))
if 90<=a<=100: #这个写法仅仅是python适用
print("成绩是A")
elif 80<=a<=89:
print("成绩是B")
elif 70<=a<=79:
print("成绩是C")
elif 60<=a<=69:
print("成绩是D")
elif 0<=a<=59:
print("成绩是E")
else:
print("输入错误")
'''
实现成绩的判断 and实现bool类型的比较
'''
a=int(input('输入成绩:'))
if 90<=a and a<=100:
print("成绩是A")
elif 80<=a and a<=89:
print("成绩是B")
elif 70<=a and a<=79:
print("成绩是C")
elif 60<=a and a<=69:
print("成绩是D")
elif 0<=a and a<=59:
print("成绩是E")
else:
print("输入错误")