print(10 > 9) # True
print(10 == 9) # False
print(10 < 9) # False
a = 200
b = 33
if b > a: # False
print("b is greater than a")
else:
print("b is not greater than a")
# b is not greater than a
Evaluate Values and Variables: bool()
- 어떤 값을 가지고 있으면 True
- 문자열이 비었다면 False
- 0이 아닌 숫자는 True
- 비어있지 않은 list, tuple, set, dict는 True
True
print(bool("Hello")) # True
print(bool(15)) # True
a = ""
print(bool(a)) # False
bool("abc")
bool(123)
bool(["apple", "cherry", "banana"])
False
bool(False)
bool(None)
bool(0)
bool("")
bool(())
bool([])
bool({})
class myclass():
def __len__(self):
return 0
myobj = myclass()
print(bool(myobj)) # False
Functions
def myFunction() :
return True
if myFunction():
print("YES!")
else:
print("NO!")
# YES!
x = 200
print(isinstance(x, int)) # True