国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Python > 正文

總結Python中邏輯運算符的使用

2020-02-23 01:11:43
字體:
來源:轉載
供稿:網友

下表列出了所有Python語言支持的邏輯運算符。假設變量a持有10和變量b持有20,則:

2015513121854474.jpg (586×254)

 示例:

試試下面的例子就明白了所有的Python編程語言提供了邏輯運算符:

#!/usr/bin/pythona = 10b = 20c = 0if ( a and b ):  print "Line 1 - a and b are true"else:  print "Line 1 - Either a is not true or b is not true"if ( a or b ):  print "Line 2 - Either a is true or b is true or both are true"else:  print "Line 2 - Neither a is true nor b is true"a = 0if ( a and b ):  print "Line 3 - a and b are true"else:  print "Line 3 - Either a is not true or b is not true"if ( a or b ):  print "Line 4 - Either a is true or b is true or both are true"else:  print "Line 4 - Neither a is true nor b is true"if not( a and b ):  print "Line 5 - Either a is not true or b is not true"else:  print "Line 5 - a and b are true"

當執行上面的程序它會產生以下結果:

Line 1 - a and b are trueLine 2 - Either a is true or b is true or both are trueLine 3 - Either a is not true or b is not trueLine 4 - Either a is true or b is true or both are trueLine 5 - Either a is not true or b is not true

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 竹溪县| 靖宇县| 介休市| 广州市| 砚山县| 辛集市| 嘉善县| 来安县| 梁山县| 祁阳县| 三台县| 大石桥市| 绥江县| 喀喇| 黄冈市| 含山县| 南投县| 兴仁县| 达尔| 沾化县| 内丘县| 竹溪县| 巴中市| 峨山| 桂东县| 东源县| 靖西县| 谢通门县| 周至县| 黄骅市| 金川县| 垦利县| 光山县| 确山县| 沧州市| 鞍山市| 南召县| 永顺县| 林芝县| 贵阳市| 肇庆市|