
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:
- Aya Expanse supports multiple languages for diverse global applications
Snapshot Aya Expanse is a cutting-edge multilingual model that has achieved exceptional performance across 23 different languages, setting a new benchmark for language understanding and generation capabilities. Why this matters The implications of Aya Expanse are significant, as it enables developers to create more inclusive and effective applications that can cater to diverse user bases… - Alibaba releases Page Agent on GitHub for public access
Snapshot GitHub’s trending page has highlighted Page Agent, an open-source project by Alibaba. This innovative tool allows for efficient and simplified web page analysis, providing developers with valuable insights into page performance and structure. Why this matters Page Agent’s ability to analyze web pages and provide actionable data has significant implications for developers. By leveraging… - Google Sheets Gemini reaches new levels of performance and accuracy
Gemini in Google Sheets has achieved state-of-the-art performance, with a 70.48% success rate in autonomously manipulating complex, real-world spreadsheets on the full SpreadsheetBench dataset. This milestone marks a significant advancement in AI-powered spreadsheet capabilities, positioning Gemini as a leader in the field. Situation The recent announcement of new beta features for Gemini in Sheets has… - Artificial intelligence boosts cardiac care in rural Australian communities
Google is partnering with leading Australian health organizations to bring new AI tools to regional communities, with a $1 million investment from Google Australia’s Digital Future Initiative. This project aims to identify heart health risks early, making proactive care possible for more people, particularly in rural Australia where individuals are 60% more likely to die… - NVIDIA GTC 2026 Offers Insights into Future Artificial Intelligence Developments
NVIDIA’s GTC 2026 conference is now underway, bringing together 30,000 attendees from 190 countries to explore the latest advancements in AI, with a focus on engineering implications. This year’s event introduces OpenClaw, the fastest-growing open source project in history, allowing attendees to build and deploy their own proactive, always-on AI assistants. What’s New with OpenClaw…








