ProgrammingHardProduct-company MCQ pattern
What is printed?
What is printed?
print(1 << 2 + 1, (1 << 2) + 1, 4 >> 1 - 1, 2 * 3 % 4 ** 2 // 3)
- A. 8 5 2 2
- B. 2 5 4 2
- C. 8 5 4 2
- D. 8 5 4 6
Correct answer: C. 8 5 4 2
Addition binds tighter than shifts, so 1 << 2 + 1 is 1 << 3. Inside the last expression ** comes first, then * % and // from left to right, giving 6 % 16 // 3 = 2.
More Python Programming questions
- What is printed on the first line? python print(0.5 + 0.25 == 0.75, 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 == 1.0)…
- What is printed? python print(round(0.5), round(1.5), round(2.5), round(-2.5), round(2.5 + 1e-15))
- What is printed? python print(round(12345, -2), round(12350, -2), round(12250, -2), round(-1234.5, -1))
- What is printed? python print(format(1234.5678, '.2f'), format(1234.5678, '.2e'), format(0.000012345, '.3g'), format(12345.6789, ',.1f'))
- What is printed? python print(str(1.0), str(1e2), str(1.5e-7), str(123456789012345678.0), str(0.1 + 0.7))
- What is printed? python print(1 / 3 3 == 1.0, 2 / 3 3 == 2.0, 10 / 3 3 == 10.0, 0.7 3 == 2.1)