nerdexam
Python_Institute

PCEP-30-02 · Question #80

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

The correct answer is B. 1.0. In Python 3, the / operator always performs true division, returning a float even when both operands are integers - so 1 / 1 evaluates to 1.0, not the integer 1. Why the distractors are wrong: A (1) would be correct in Python 2, or if the // floor division operator were used (1…

Question

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

Options

  • A1
  • B1.0
  • CThis can not be predicted.
  • DThis can not be evaluated.

How the community answered

(32 responses)
  • A
    3% (1)
  • B
    81% (26)
  • C
    13% (4)
  • D
    3% (1)

Explanation

In Python 3, the / operator always performs true division, returning a float even when both operands are integers - so 1 / 1 evaluates to 1.0, not the integer 1.

Why the distractors are wrong:

  • A (1) would be correct in Python 2, or if the // floor division operator were used (1 // 1 == 1). In Python 3, / never returns an int.
  • C is wrong because the result is entirely predictable - Python's division behavior is well-defined and deterministic.
  • D is wrong because the expression is perfectly valid Python and evaluates without error.

Memory tip: Think of / as "always floating" in Python 3 - if you want an integer result, you need the double-slash // operator. The single slash always gives you a decimal point.

Community Discussion

No community discussion yet for this question.

Full PCEP-30-02 Practice