首页 > 编程语言 >【笨方法学python】ex28 - 布尔表达式练习

【笨方法学python】ex28 - 布尔表达式练习

时间:2022-10-08 05:44:05浏览次数:67  
标签:False python testing test result print ex28 True 方法学

代码如下:

点击查看代码
a = True and True
print "The result of 'True and True' is", a

b = False and False
print "The result of 'False and False' is", b

c = 1 == 1 and 2 == 1
print "The result of '1 == 1 and 2 == 1' is", c

d = "test" == "test"
print """The result of '"test" == "test"' is""", d

e = 1 == 1 or 2 != 1
print "The result of '1 == 1 or 2 != 1' is", e

f = True and 1 == 1
print "The result of 'True and 1 == 1' is", f

g = False and 0 != 0
print "The result of 'False and 0 != 0' is", g

h = True or 1 == 1
print "The result of 'True or 1 == 1' is", h

i = "test" == "testing"
print """The result of '"test" == "testing"' is""", i

j = 1 != 0 and 2 == 1
print "The result of '1 != 0 and 2 == 1' is", j

k = "test" != "testing"
print """The result of '"test" != "testing"' is""", k

m = "test" == 1
print """The result of '"test" == 1' is""", m

n = not (True and False)
print "The result of 'not (True and False)' is", n

o = not (1 == 1 and 0 != 1)
print "The result of 'not (1 == 1 and 0 != 1)' is", o

p = not (10 == 1 or 1000 == 1000)
print "The result of 'not (10 == 1 or 1000 == 1000)' is", p

q = not (1 != 10 or 3 == 4)
print "The result of 'not (1 != 10 or 3 == 4)' is", q

r = not ("testing" == "testing" and "Zed" == "Cool Guy")
print """The result of 'not ("testing" == "testing" and "Zed" == "Cool Guy")' is""", r

s = 1 == 1 and not ("testing" == 1 or 1 == 0)
print """The result of '1 == 1 and not ("testing" == 1 or 1 == 0)' is""", s

t = "chunky" == "bacon" and not (3 == 4 or 3 == 3)
print """The result of '"chunky" == "bacon" and not (3 == 4 or 3 == 3)' is""", t

u = 3 == 3 and not ("testing" == "testing" or "Python" == "Fun")
print """The result of '3 == 3 and not ("testing" == "testing" or "Python" == "Fun")' is""", u

执行结果:
image

标签:False,python,testing,test,result,print,ex28,True,方法学
From: https://www.cnblogs.com/TiramisuPS/p/16767816.html

相关文章