Lesson guide
What this Python exercise practices
Use Boolean Values is a beginner practice lesson that focuses on functions, parameters, return values. It is designed to be solved in about 6 minutes with examples, starter code, and test feedback.
Prerequisites
- Python variables
- Function parameters
- Return values
Difficulty and time
- Level
- Beginner
- Estimated time
- 6 minutes
Related public exercises
Summary
Learn how to produce and return boolean values using comparisons. Practice writing a simple condition that yields True or False.
Problem statement
Write a function is_adult(age) that returns True if the given age is 18 or older, and False otherwise. Use a comparison expression to produce the boolean value directly.
Task
Implement a function that returns a boolean based on a numeric comparison (is age an adult?).
Examples
Example - under 18
Input
is_adult(16)
Output
False
Explanation
16 is less than 18, so the function returns False.
Example - exactly 18
Input
is_adult(18)
Output
True
Explanation
Age 18 meets the threshold for being an adult, so the function returns True.
Input format
A single integer parameter: age (e.g., 17).
Output format
A boolean value: True or False.
Constraints
age is an integer between -1000 and 1000 (may be negative in edge cases).
Samples
Sample input 0
is_adult(20)
Sample output 0
True
Explanation 0
20 is >= 18, so return True.
AI assistant
Ask me anything!
Need help? I can explain the core idea behind this problem, review your current code, and give targeted hints. Use “Teach Theory” for the concept, “Get AI hint” for a quick scaffold nudge, or ask a specific question below.
Chat history is temporary and will not be saved.
Free preview includes 1 Teach Theory response and 1 AI hint per unlocked preview lesson.