-
ํ์ด์ฌ | #4 ๋ฐ์ดํฐํ์ (Boolean)์นดํ ๊ณ ๋ฆฌ ์์ 2023. 8. 17. 23:12
๋ถ๋ฆฌ์ธ ๋ณ์
true, false ๊ฐ์ ๋ํ๋ธ๋ค.
print(20 > 10) #True print(10 == 9) #False
if ์กฐ๊ฑด๋ฌธ์์ ํจ๊ป ์ฌ์ฉ๋๋ค.
age = 26 age2 = 16 if age > age2: print("age is older than age2") else: print("age is not older than age2")
print(bool("hello")) #๋ฌธ์์ด true๊ฐ ๋ฆฌํด print(bool([1,2,3])) # true ๊ฐ ๋ฆฌํด print(bool(12)) #true ๊ฐ ๋ฆฌํด print(bool("")) #๋น๋ฌธ์์ด false ๊ฐ ๋ฆฌํด print(bool(0)) #0 false ๊ฐ ๋ฆฌํด print(bool([])) #[] flase ๊ฐ ๋ฆฌํด print(bool(None)) #None flase ๊ฐ ๋ฆฌํด
https://www.w3schools.com/python/python_booleans.asp