Practice question from Python Fundamentals

What is the output of this code? A. 2.5 B. 2 C. 3 D. 2.0 E. Error

x = 5
y = 2
print(x // y)

Answer

B

Explanation

The // operator performs floor division, which divides and returns the largest integer less than or equal to the result. 5 // 2 = 2 (the decimal part is truncated, not rounded).

More questions from Python Programming