Check if a Number Is in Range
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 lessonCreate a variable num set to 42. Use a chained comparison to check if num is between 1 and 100 (inclusive). Print the result.
Expected output:
True# Create num and check if it's between 1 and 100 (inclusive)
More booleans and operators exercises
- Validate a String LengthBeginner
- Predict the Logical OutputBeginner
- Fix the Comparison BugBeginner
- Check for a Leap YearBeginner
- Evaluate Truthiness with bool()Beginner
All Python exercises · 50 practice problems · Python Fundamentals quiz