python语言 写一个判断10个标志的判断
时间: 2023-10-11 16:07:08 浏览: 73
以下是一个简单的Python程序,可以判断10个标志:
```
flag1 = True
flag2 = False
flag3 = True
flag4 = False
flag5 = True
flag6 = False
flag7 = True
flag8 = False
flag9 = True
flag10 = False
if flag1:
print("Flag 1 is True")
else:
print("Flag 1 is False")
if flag2:
print("Flag 2 is True")
else:
print("Flag 2 is False")
if flag3:
print("Flag 3 is True")
else:
print("Flag 3 is False")
if flag4:
print("Flag 4 is True")
else:
print("Flag 4 is False")
if flag5:
print("Flag 5 is True")
else:
print("Flag 5 is False")
if flag6:
print("Flag 6 is True")
else:
print("Flag 6 is False")
if flag7:
print("Flag 7 is True")
else:
print("Flag 7 is False")
if flag8:
print("Flag 8 is True")
else:
print("Flag 8 is False")
if flag9:
print("Flag 9 is True")
else:
print("Flag 9 is False")
if flag10:
print("Flag 10 is True")
else:
print("Flag 10 is False")
```
这个程序定义了10个标志,每个标志的值为True或False。然后,使用if语句对每个标志进行测试,如果标志为True,则输出“Flag X is True”,否则输出“Flag X is False”,其中X为标志的编号。
阅读全文