ProgrammingModerateTCS NQT · Infosys
What is printed?
What is printed?
print(5 // 2 ** 2, 5 >> 2, 5 / 2 ** 2)
- A. 1 1 1.2
- B. 2 1 1.25
- C. 1 1 1.25
- 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
- What is printed? python print(1 + 2 3 2 // 4 % 5, (1 + 2) 3 2 // 4 % 5)
- What is printed? python print(1 == 1.0 and '1' != 1, [1, 2] == [1.0, 2.0], (1, 'a') == (1.0, 'a'))
- What is printed? python print(set([1, 2]) == {1.0, 2.0}, {1: 'x'}.get(1.0), {'1': 2}.get(1))
- What is printed? python print(2 63 - 1 == 9223372036854775807, (2 63) % 10, -2 63 // 10)
- What is printed? python print(str(10 15 / 10), str(10 16 / 10), 10 16 // 10)
- What is printed? python print('%.3g' % 0.0001234, '%.3g' % 123456.0, '%g' % 0.5)