← Back to Recursion
Question 603
Even By Two Steps
Even By Two Steps
Complete is_even(n: int) -> bool so it returns True for an even non-negative integer and False for an odd one, by recursion and without the remainder operator. Two base cases are written: 0 is even and 1 is odd. Add the recursive case, which returns whether n - 2 is even, because taking two away never changes the answer. Do NOT write a main block or any top-level test code; the tests construct the calls. Input: one integer n, no prompt, which the tests read and pass to your function before printing the value it returns.
Expected Output:
True= newline. The output ends with a newline — print one after the last line.
Hints2 available
Sign in to use hintsTopics:
Recursion
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Ctrl+Space to expand shortcuts (pr, inp, def)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.