ProgrammingVery hardTCS NQT · Accenture
What is printed?
What is printed?
print('{0:>{1}}'.format('x', 3), '{:0>3}'.format(7), '{:x<4}'.format('ab'), '{:^7.3f}|'.format(2.5))- A. x 007 abxx 2.500 |
- B. x 007 abxx 2.600 |
- C. x 007 abxx 2.5 |
- D. x 700 abxx 2.500 |
Correct answer: A. x 007 abxx 2.500 |
The nested width 3 right-aligns x, and the 0 fill with > alignment pads 7 to 007. The x fill pads ab on the right, and the centred 2.500 in seven columns gets one space on each side.
More Python Programming questions
- What is printed? python print(1 == True == 1.0, 2 > 1 == True, (2 > 1) == True, 1 < 2 == True)
- What is printed? python print(int(' 0x1f ', 16), int('1e3', 16), float('1e3'))
- What is printed? python from collections import Counter c = Counter(['x', 'y', 'x', 'z', 'y', 'x']) print(c.mostcommon()…
- What is printed? python print(10 % 3 2, 10 % (3 2), (10 % 3) 2, -10 % 3 2)
- What is printed? python print(list(range(10, 0, -3)), list(range(-1, -10, -4)), len(range(0, 10, 3)), range(5)[-1])
- What is printed? python print(len('anb'), len('anb'), len(r'anb'), len('arb'))