bool() — Python Technical Interview Questions & Answers
bool()
bool()
- bool() is built into Python. You do not import it. Freshers only need one honest call and the printed result — not a long definition.
- bool() — output: False then True. 0 is falsy; non-empty string is true.
- Wrong type often raises TypeError. Empty values matter for bool/all/any. Don’t mix bool up with a similar name (sorted vs sort, int vs float).
Technical Interview Tip: Call bool() once and say what prints.
Code Examples for bool()
Example
# bool()
print(bool(0))
print(bool("Asha"))
bool() — output: False then True. 0 is falsy; non-empty string is true.
How to Explain bool() to an Interviewer
Explain bool() as if you are teaching a junior — definition, then one tiny script.
bool() is built-in — no import. One call + exact output.
What does the example print, and why?
bool() — output: False then True
What mistake do freshers make with bool()?
Wrong type → TypeError.