Even or Odd Classifier

Easy ⏱ 8 min 82% acceptance ★★★★★ 4.8
Write a function classify_parity(n) that returns the string "Even" if the integer n is even, and "Odd" otherwise. This is the smallest possible if/else warm-up — get the branch condition exactly right.

Examples

Example 1
Input
classify_parity(4)
Output
"Even"
Explanation

4 is divisible by 2.

Example 2
Input
classify_parity(7)
Output
"Odd"
Explanation

7 is not divisible by 2.

Constraints

  • n is an integer (can be negative or zero).

Topics

Conditional Statementsif/else

Companies

AmazonTCSInfosys

Hints

Hint 1

Use the modulo operator `%` to test divisibility by 2.

Hint 2

Zero counts as even.

Loading the Python runtime… Run executes your code and shows printed output; Submit checks your function against this problem's examples.