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

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.

主站蜘蛛池模板: 许昌市| 临海市| 青海省| 白玉县| 盘锦市| 万山特区| 沈阳市| 保靖县| 渭源县| 承德县| 塔河县| 裕民县| 梅州市| 房山区| 文登市| 中西区| 隆安县| 兴海县| 达州市| 堆龙德庆县| 孝义市| 宁城县| 莒南县| 章丘市| 铜川市| 甘谷县| 柯坪县| 甘南县| 苍溪县| 长泰县| 德格县| 大英县| 册亨县| 壶关县| 寻乌县| 商洛市| 赤城县| 滦南县| 彩票| 营口市| 甘德县|