官术网_书友最值得收藏!

Understanding boolean expressions

Boolean expression syntax is a little bit weird or unusual, at least in Python:

print (1 == 3)

The output of the above code is as follows:

False

As usual, we have the double equal symbol that can test for equality between two values. So does 1 equal 3, no it doesn't, therefore False. The value False is a special value designated by F. Remember that when you're trying to test, when you're doing Boolean stuff, the relevant keywords are True with a T and False with an F. That's a little bit different from other languages that I've worked with, so keep that in mind.

print (True or False)

The output of the above code is as follows:

True

Well, True or False is True, because one of them is True, you run it and it comes back True.

主站蜘蛛池模板: 公主岭市| 蒙自县| 东港市| 监利县| 常德市| 来宾市| 鸡东县| 广汉市| 菏泽市| 金乡县| 温宿县| 黄平县| 永福县| 珲春市| 金沙县| 宾川县| 普兰店市| 福泉市| 永春县| 寻乌县| 张掖市| 奉化市| 凤冈县| 杨浦区| 瑞昌市| 南川市| 靖边县| 临江市| 连平县| 威远县| 大厂| 阿拉善右旗| 兰坪| 安新县| 庆阳市| 西乡县| 南木林县| 家居| 正定县| 通道| 枝江市|