PROBLEM 35
Easy

Is the Last Digit Even?

Programming Basics · Python

</>
STATUS Not solved

TASK

Problem

#35

Given non-negative `n`, print `YES` if its last digit is even, otherwise `NO`.

EXAMPLE

Example

Input
1234
Output
YES

LIMITS

Constraints

Quantities, prices, and balances are integers from 0 to 10^9; other integer inputs have absolute value at most 10^9.
📖
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 `'YES'` shows how this idea is applied to the task data.

For this task, pay special attention to `int(input())`: it connects the concept above to the concrete computation or program action.

**Focus: “Is the Last Digit Even?”.** The same basic mechanism is used in a different context here, so understand the operation itself rather than memorizing a finished line of code.

💡
NEED HELP? Hints
+

['Take the last digit with `% 10`, then test parity.']

ANSWER Solution
+
n = int(input())
last = n % 10
if last % 2 == 0:
    print('YES')
else:
    print('NO')