Python布尔练习(转载)

关于Python的布尔值练习

#!/usr/bin/env python
# -*- coding:utf-8 -*-
# zs

# 布尔练习
a = True and True
print('a = ',a)
b = False and True
print('b = ',b)
c = True or False
print('c = ', c)
d = not(True and False)
print('d = ' ,d)
e = 1 == 1
f = 2 == 1
print('e = ',e)
print('f = ',f)
g = 1==1or 2!=1
print('g = ',g)

h = 1>2 or 2>1
print('h = ',h)

 

输出

D:\python\untitled1\venv\Scripts\python.exe D:/python/untitled1/pythontest/循环.py
a =  True
b =  False
c =  True
d =  True
e =  True
f =  False
g =  True
h =  True

Process finished with exit code 0

posted @ 2020-08-31 09:33  Kot  阅读(145)  评论(0编辑  收藏  举报