Even or Odd
Programming Basics · Python
TASK
Problem
Given integer `n`, print `EVEN` if it is even, otherwise `ODD`.
EXAMPLE
Example
17
ODD
LIMITS
Constraints
All integer inputs have absolute value at most 10^9; any additional relationships between them are stated directly in the task.
LEARN
Theory for this problem
+
`input()` reads data entered by the user. The result of `input()` is initially a string. `int()` converts a numeric string into an integer. The `%` operator returns the remainder after division. Comparison operators `==`, `!=`, `<`, `>`, `<=`, `>=` compare values and produce `True` or `False`. `if` checks a condition and runs its block when the condition is true. `else` runs when the corresponding `if` condition is false. `print()` displays the program result. Print only what the problem statement requires.
**Connection to this task.** The `%` operator returns a division remainder. Therefore `n % k` is useful for divisibility checks and for working with the last digits of a number. The expression `'EVEN'` shows how this idea is applied to the task data.
NEED HELP?
Hints
+
['Check `n % 2 == 0`.']
ANSWER
Solution
+
n = int(input())
if n % 2 == 0:
print('EVEN')
else:
print('ODD')