10 подписчиков
📑 Boolean Values of Objects
📑 Task
1) What will be printed
2) Explain the result with a code snippet, then remove
one punctuation character so the program result would be 0
x = 0,
print(1 if x and 1 else 0)
📑 Answer
1) 1
2)
x = 0,
print(type(x), bool(x), bool(x and 1))
print(1 if x and 1 else 0)
x = 0
print(type(x), bool(x), bool(x and 1))
print(1 if x and 1 else 0)
Около минуты
23 апреля 2024