Menu

Sign in to track your progress and unlock all features.

Theme style

Log in

Problem No 4

Use Boolean Values

Easy

6 minute session

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.

Code editor
Loading editor…

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.

03:39 AM

Free preview includes 1 Teach Theory response and 1 AI hint per unlocked preview lesson.