Evaluate Truthiness with bool()
Beginner · Write the code · from Python Booleans, Comparisons, and All Operators Explained
From the lesson: Python Booleans, Comparisons, and All Operators Explained
Every day you make yes-or-no decisions. "Is it raining?" "Do I have enough money?" "Is my password correct?" Computers make the same kind of decisions, and they use booleans to do it.
Read the lessonUse the bool() function to print the truthiness of these values, each on its own line and in this exact order:
1. 0
2. "hello"
3. ""
4. 42
5. None
Expected output:
False
True
False
True
False# Print the truthiness of each value using bool()
More booleans and operators exercises
- Check if a Number Is in RangeBeginner
- Validate a String LengthBeginner
- Predict the Logical OutputBeginner
- Fix the Comparison BugBeginner
- Check for a Leap YearBeginner
All Python exercises · 50 practice problems · Python Fundamentals quiz