# print(True and True)
# # true
# print(False and True)
# # false
# print(1 == 1 and 2 == 1)
# # false
# print("test" == "test")
# # true
# print(1 == 1 or 2 != 1)
# # true
# print(True and 1 == 1)
# # true
# print(False and 0 != 0)
# # false
# print(True or 1 == 1)
# # true
# print("test" == "testing")
# # false
# print(1 != 0 and 2 == 1)
# # false
# print("test" != "testing")
# # true
# print("test" == 1)
# # false
print(not (True and False))
# true
print(not (1 == 1 and 0 != 1))
# false
print(not (10 == 1 or 1000 == 1000))
# false
print(not (1 != 10 or 3 == 4))
# false
print(not ("testing" == "testing" and "Zed" == "Cool Guy"))
# true
print(1 == 1 and not ("testing" == 1 or 1 == 0))
# true
print(3 == 3 and not ("testing" == "testing" or "Python" == "Fun"))
# false
這一節(jié)課比較重要的是記住關(guān)系運(yùn)算符的表示方法:
還有邏輯運(yùn)算符的推算,這個(gè)在高中數(shù)學(xué)有學(xué)過類似的關(guān)系判定,有一定基礎(chǔ)較好理解和記憶。
其中要特別記住的是,or這個(gè)邏輯運(yùn)算符,含義是or前面和后面只要有任意一個(gè)為true,or這個(gè)式子也就是true。
“非0即為真,非真即為假” ?是對(duì)not的口訣。
新的字符串知識(shí):
str.startswith(str1,start,end) ? ? ?str.endswith(str1,start,end)
括號(hào)里面start是索引數(shù)字,str1是字符串中的片段