ProgrammingHardGATE CS · Product-company placement

What is printed?

What is printed?
print(10 / 4, 10 // 4, -10 // 4, 10 % -4, 2 ** -2, 7 // 2.0)
  1. A. 2.5 2 -2 2 0.25 3.0
  2. B. 2.5 2 -3 2 0.25 3
  3. C. 2 2 -3 -2 0.25 3.0
  4. D. 2.5 2 -3 -2 0.25 3.0

Correct answer: D. 2.5 2 -3 -2 0.25 3.0

/ always gives a float; // floors (so -10 // 4 = -3); % takes the divisor's sign (10 % -4 = -2); a negative exponent gives a float; // with a float operand returns a float.

More Python Programming questions

Exams that ask this topic