北京中科白癜风医院热心公益 http://baijiahao.baidu.com/s?id=1700353148116242762&wfr=spider&for=pc逻辑运算符逻辑运算符包括and“与”、or“或”、not“非”。假设a=6,b=66。and与:xandy,如果x为假(False),那么返回假,否则返回y的值。如:aandb,返回b的值66。or或:xory,如果x为真(True),那么返回x的值,否则返回y的值。如:aorb,返回a的值6。not非:notx,如果x为假(False),则返回真(True);如果x为真(True),则返回假(False)。即取反。如:nota,返回False。练一练a=8b=88c=0#and运算符print(TrueandTrue)print(TrueandFalse)print(FalseandTrue)print(FalseandFalse)#or运算符print(TrueorTrue)print(TrueorFalse)print(FalseorTrue)print(FalseorFalse)#not运算符print(notTrue)print(notFalse)print(aandb)print(aorb)print(bandc)print(borc)print(nota)print(notc)将上面代码保存为logicalOperator.py,在IDLE中运行结果如下:
转载请注明:http://www.aierlanlan.com/rzdk/7063.html