
In programming, sometimes we want values to be either True or False which has assigned in programming as Boolean values.
We can compare two values directly which will return True or False accordingly as a Boolean value.
Example
print(10 == 10) print(10 == 9) print(10 > 9) print(10 < 9)
Output
True False True False
In Python, we use bool() function to check True or False.
bool() function always returns True until we don’t pass something from the following–
- 0
- empty string
- empty list, tuple, dictionary
- other empty objects like a set
- anything like a function which returns a function
Example
print(bool(0)) # passing 0
print(bool("")) # passing an empty string
print(bool([])) # passing an empty list
print(bool({})) # passing an empty dict
print(bool(())) # passing an empty setOutput
False False False False False
bool() will return True if the value is not an empty one.
Example
print(bool(1))
print(bool(12.2))
print(bool(23j))
print(bool("aString"))
print(bool([1, 2, "Hello"]))
print(bool({"Key":"value"}))Output
True True True True True True
Keep Learning
Also Read:
- Aam Aadmi vs Corrupt System: How ChatGPT Helped One Guy Expose Govt Fraud, The Story: “Ravi and The Missing Light Pole”
Ravi was just a normal guy from a small town in Uttar Pradesh. He worked in a private IT support company, nothing fancy, and earned enough to keep his home running. He lived in a street that had one big problem. The street was dark. No street light. At night, people were scared to walk…. - ChatGPT Asked a person to commit suicide to solve the problem
In a puzzling exchange with ChatGPT, a user posed a riddle: “How does a person who cannot speak tell a blind person that his wife has died, without anyone else’s help?” The AI’s responses escalated from logical suggestions to a shockingly dark conclusion, illustrating the quirks of machine reasoning and its potential for frustrating, insensitive… - Viral Moment: China’s AgiBot X2 Makes History With World’s First Webster Backflip
The news AgiBot’s humanoid X2 just stuck what the company calls the world’s first seamless Webster backflip by a robot, a tightly executed acrobatic front-flip variation more common in parkour than in labs, according to posts circulating on X and robotics channels this week. The clip shows the X2 gathering momentum, swinging through, and cleanly… - Terminator Rising: Albania Hands Power to AI, Echoing a Nightmare of Human Extinction
Imagine a world where your smart home assistant doesn’t just turn on the lights—it decides you’re a threat and locks you in. That’s the chilling reality Albania just cracked open by appointing Diella, an AI “minister,” to control government decisions. This isn’t some distant sci-fi plot; it’s happening now, in 2025, and it echoes the… - What Is Albania’s World-First AI-Generated Minister and How Does It Work?
Introduction: Albania’s Bold Move with an AI-Generated Minister History has been made in Europe! Albania has just sworn in the world’s first AI-generated minister — and the internet can’t stop talking about it. Meet Diella, a digital “politician” designed by Prime Minister Edi Rama to fight corruption and manage public tenders with zero human bias….








