条件控制语句:
if condition (条件):
要执行的语句A
要执行的语句B
要执行的语句C
什么是条件:例如1>2= False ,条件的真实值即True 和False ,
if 后的条件如果为True,则if下的语句执行,即执行语句A、B、和if语句外的语句C。C
if后的条件如果为False,则不执行if语句内的A、B,执行语句C
currency = 78
price = 78
if currency>=price:
print("购买成功","当前余额为",currency-price)
else :
print("购买失败,请充值")
购买成功 当前余额为 0
第二种条件控制语句:
if conditio
要执行的语句A
elif:
要执行的语句B
else:
要执行的语句C
score =90
if 100>=score>=85:
print("A")
elif 60<=score<85:
print("B")
else :
print("C")