ProgrammingModerateTCS NQT · Infosys

What is printed?

What is printed?
print(5 // 2 ** 2, 5 >> 2, 5 / 2 ** 2)
  1. A. 1 1 1.2
  2. B. 2 1 1.25
  3. C. 1 1 1.25
  4. D. 1 2 1.25

Correct answer: C. 1 1 1.25

2 ** 2 binds tighter than //, so 5 // 4 is 1. Shifting 5 right by two gives 1, and 5 / 4 is the float 1.25.

More Python Programming questions

Exams that ask this topic