1、条件成立执行
>>> a = 50
>>> if a > 10:
print("xxx")
xxx
>>> if a < 10:
print("yyy")
>>> if a == 50:
print("zzz")
zzz
score = int(input("score="))
if 100 >= score >= 90:
print("AAA")
if 90 > score >= 80:
print("BBB")
if 80 > score >= 60:
print("CCC")
if 60 > score >= 0:
print("DDD")
if score > 100 or score <= 0:
print("error! range: 0-100")
score = int(input("score="))
if 100 >= score >=90:
print("AAA")
else:
if 90 > score >= 80:
print("BBB")
else:
if 80 > score >= 60:
print("CCC")
else:
if 60 > score >= 0:
print("DDD")
else:
print("error! range:0-100")
score = int(input("score:"))
if 100 >= score >= 90:
print("AAA")
elif 90 > score >= 80:
print("BBB")
elif 80 > score >= 60:
print("CCC")
elif 60 > score >= 0:
print("DDD")
else:
print("error! range: 0-100")
>>> test1 = ["aaa","bbb","ccc","ddd"]
>>> for i in test1:
if i == "aaa":
print(i.upper())
else:
print(i.title())
AAA
Bbb
Ccc
Ddd
>>> for i in test1:
if i == "bbb":
print(i.upper())
else:
print("_".join(i))
a_a_a
BBB
c_c_c
d_d_d
>>> test1 = ["aaa","bbb","ccc","ddd"]
>>> for i in test1:
if i == "ccc":
print(i.upper())
else:
print(i.replace("a","xxx"))
xxxxxxxxx
bbb
CCC
ddd
>>> for i in test1:
if i == "aaa" or i == "bbb":
print("+".join(i))
else:
print(i.title())
a+a+a
b+b+b
Ccc
Ddd