ProgrammingModerateProduct-company MCQ pattern
What is printed?
What is printed?
print([10, 20, 30][True], (5).bit_length(), (True).bit_length(), (-1).bit_length())
- A. 10 3 1 1
- B. 20 3 2 1
- C. 20 3 1 1
- D. 20 3 0 1
Correct answer: C. 20 3 1 1
True is 1 when used as an index, so it picks 20. bit_length uses the magnitude, so 5 needs 3 bits and both True and -1 need 1 bit.
More Python Programming questions
- What is printed? python print(round(7.5), round(6.5), round(-7.5), round(7.5000001))
- What is printed? python print(-7.5 % 2, 7.5 % -2, -0.0 % 3)
- What is printed? python words = 'the quick brown the lazy the'.split() counts = {} for w in words: counts[w] = counts.get(w, 0) + 1…
- What is printed? python print('%.3f' % 1.0005, '%.1f' % 0.25, '%.1f' % 0.35, round(0.35, 1))
- What is printed? python from collections import Counter c = Counter('mississippi') print(c.mostcommon(2), sorted(c.items(), key=lambda kv…
- What is printed? python x = 5 y = x if x > 3 else 0 + 1 if x else -1 print(y, (lambda a, b=2: a b)(3), (lambda a: sum(a))(1, 2, 3))