ProgrammingHardTCS CodeVita · Infosys HackWithInfy
What is printed?
What is printed?
print('%5.2f|%-4d|%04x' % (3.14159, 7, 255))- A. 3.14|7 |00ff
- B. 3.14|7 |0ff
- C. 3.14| 7|00fe
- D. 3.14|7 |ff
Correct answer: A. 3.14|7 |00ff
%5.2f gives width 5 with two decimals, so ' 3.14' keeps a leading space. %-4d left-aligns 7 in four columns, and %04x zero-pads 255 in hex to 00ff.
More Python Programming questions
- What is printed? python a = {1, 2, 3, 4} b = {3, 4, 5} print(a ^ b, a - b, b <= a, a | b == {1, 2, 3, 4, 5})
- What is printed? python print(int(2.675 100), round(2.675, 2))
- What is printed? python print(-7.5 // 2, -7.5 % 2)
- What is printed? python print(pow(3, 0, 1), pow(3, 0), 0 0)
- What is printed? python x = [1, 2, 3, 4, 5] print(x[-1:-4:-1], x[::-1][:2], x[::2][-1])
- What is printed? python import bisect a = [3, 1, 2, 5, 4] seen = [] inv = 0 for x in a: inv += len(seen) - bisect.bisectright(seen, x)…