Identify the output of the Python Command: print(22.0//5)

2023

Identify the output of the Python Command: print(22.0//5)

  1. A.

    4.4 / 4.4

  2. B.

    4 / 4

  3. C.

    4.0 / 4.0

  4. D.

    2 / 2

Attempted by 1792 students.

Show answer & explanation

Correct answer: C

Key insight: the // operator performs floor division. When any operand is a float, the result is a float equal to the floor of the true quotient.

  • Compute true division: 22.0 / 5 = 4.4.

  • Apply floor division: floor(4.4) = 4.0.

  • Because a float was involved, the result is returned as a float: the output is 4.0.

Why the other choices are incorrect:

  • The option showing '4.4 / 4.4' displays the true-division result (4.4), but // performs floor division, so this is not correct.

  • The option showing '4 / 4' does not represent the floor-division result for this expression; 4/4 equals 1, and 22.0 // 5 equals 4.0.

  • The option showing '2 / 2' is unrelated to this calculation and is incorrect.

Explore the full course: Rssb Senior Computer Instructor