Python基础学习-05

Python基础学习-05

# Python bool
# compare
print(10 > 9)
print(10 == 9)
print(10 < 9)

a = 100
b = 30
if b > a:
    print("b大于a")
else:
    print("b不大于a")

# assessed value
print(bool("喜羊羊"))
print(bool(20))

x = "灰太狼"
y = "15"
print(bool(x))
print(bool(y))

# bool True
bool("abc")
bool(123)
bool(["apple", "cherry", "banana"])

# bool False
bool(False)
bool(None)
bool(0)
bool("")
bool(())
bool([])
bool({})

# function return bool
def my_function ():
    return True
print(my_function())

if my_function():
    print("YES!")
else:
    print("NO!")

# Verifies that an object belongs to some kind of data
x = 200
print(isinstance(x, int))

# Test
"""
回答下面语句返回值
"""
print(10 > 9)
# True
print(10 == 9)
# False
print(10 < 9)
# False
print(bool("abc"))
# True
print(bool(0))
# False
上一篇:05-软件测试类型


下一篇:实战java虚拟机-jvm故障诊断与性能优化-读书笔记