# 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
这一节课比较重要的是记住关系运算符的表示方法:
还有逻辑运算符的推算,这个在高中数学有学过类似的关系判定,有一定基础较好理解和记忆。
其中要特别记住的是,or这个逻辑运算符,含义是or前面和后面只要有任意一个为true,or这个式子也就是true。
“非0即为真,非真即为假” 是对not的口诀。
新的字符串知识:
str.startswith(str1,start,end) str.endswith(str1,start,end)
括号里面start是索引数字,str1是字符串中的片段