nerdexam
Python_Institute

PCEP-30-02 · Question #60

What would you insert instead of ???, so that the program checks for even numbers? if ???: print('x is an even number')

The correct answer is C. x % 2 == 0. Option C (x % 2 == 0) is correct because the modulo operator % returns the remainder after division - dividing any even number by 2 always leaves a remainder of 0, making this the definition of "even." Why the others fail: A (x % "even") is invalid syntax - you can't use modulo…

Question

What would you insert instead of ???, so that the program checks for even numbers? if ???: print('x is an even number')

Options

  • Ax % "even" == True
  • Bx % 2 == 1
  • Cx % 2 == 0
  • Dx % x == 0
  • Ex % 1 == 2

How the community answered

(25 responses)
  • A
    16% (4)
  • B
    4% (1)
  • C
    72% (18)
  • E
    8% (2)

Explanation

Option C (x % 2 == 0) is correct because the modulo operator % returns the remainder after division - dividing any even number by 2 always leaves a remainder of 0, making this the definition of "even."

Why the others fail:

  • A (x % "even") is invalid syntax - you can't use modulo with a string.
  • B (x % 2 == 1) is the check for odd numbers, not even ones.
  • D (x % x == 0) always evaluates to True for any non-zero number (anything divided by itself has remainder 0), so it doesn't distinguish even from odd.
  • E (x % 1 == 2) is impossible - the remainder when dividing by 1 is always 0, never 2.

Memory tip: Think "even → equal halves → remainder zero" - % 2 == 0 means the number splits evenly into two parts with nothing left over.

Community Discussion

No community discussion yet for this question.

Full PCEP-30-02 Practice