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

首頁 > 編程 > Python > 正文

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

2019-11-25 17:29:04
字體:
來源:轉載
供稿:網友

下表列出了所有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

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 大庆市| 长丰县| 武鸣县| 泽普县| 齐齐哈尔市| 湘乡市| 洞口县| 沾化县| 扬州市| 平陆县| 安岳县| 铜川市| 深水埗区| 喀喇沁旗| 当阳市| 襄垣县| 瓦房店市| 区。| 四子王旗| 沾化县| 阿拉善右旗| 盐亭县| 兴山县| 旬邑县| 长沙市| 巴彦淖尔市| 太康县| 泰来县| 凯里市| 黑河市| 阿坝县| 南涧| 科尔| 黔东| 克东县| 英吉沙县| 阿城市| 天镇县| 凤凰县| 台东市| 洪湖市|