nerdexam
Python_Institute

PCEP-30-02 · Question #103

What is the expected output of the following code? print (1 // 2)

The correct answer is D. 0. 1 // 2 uses Python's floor division operator (//), which divides and then rounds the result down to the nearest whole integer. Since 1 ÷ 2 = 0.5, flooring that gives 0 - an int, not a float - making D correct. Why the others are wrong: A (0.5) - that's the result of regular…

Question

What is the expected output of the following code? print (1 // 2)

Options

  • A0.5
  • B0.0
  • CNone of the above.
  • D0

How the community answered

(26 responses)
  • A
    8% (2)
  • B
    4% (1)
  • C
    15% (4)
  • D
    73% (19)

Explanation

1 // 2 uses Python's floor division operator (//), which divides and then rounds the result down to the nearest whole integer. Since 1 ÷ 2 = 0.5, flooring that gives 0 - an int, not a float - making D correct.

Why the others are wrong:

  • A (0.5) - that's the result of regular division (1 / 2), which returns a float. The // operator strips the decimal.
  • B (0.0) - floor division between two ints returns an int, not a float. 0.0 would only appear if at least one operand were a float (e.g., 1.0 // 2).
  • C (None of the above) - incorrect; D is a valid answer.

Memory tip: Think of // as "chop off the decimal" - it always floors toward negative infinity, so 1 // 2 → 0, and -1 // 2 → -1 (not 0). One slash / gives a float; two slashes // give a whole number.

Community Discussion

No community discussion yet for this question.

Full PCEP-30-02 Practice