Lesson guide
What this Python exercise practices
Check Divisible by Three 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
Practice path
Summary
Determine whether a given integer is divisible by 3.
Problem statement
Given an integer n, return True if n is divisible by 3, otherwise return False. Zero is considered divisible by 3. The function should accept negative integers as well.
Task
Write a function that returns True if an integer is divisible by 3, otherwise False.
Examples
Example
Input
9
Output
True
Explanation
9 % 3 == 0, so 9 is divisible by 3.
Input format
A single integer n.
Output format
A boolean: True if n is divisible by 3, otherwise False.
Constraints
-10**9 <= n <= 10**9 (typical integer range). Only integers will be provided.
Samples
Sample input 0
10
Sample output 0
False
Explanation 0
10 is not divisible by 3.
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.