ProgrammingHardTCS NQT · Wipro pattern
What is printed?
What is printed?
print('%-5s|%5s|' % ('ab', 'cd'), '%(x)d-%(y)s' % {'x': 1, 'y': 'z'})- A. ab | ce| 1-z
- B. ab | cd| 1-y
- C. ab | dc| 1-z
- D. ab | cd| 1-z
Correct answer: D. ab | cd| 1-z
%-5s left-aligns ab in five columns, and %5s right-aligns cd in five columns. The mapping keys x and y fill the named fields, which gives 1 and z.
More Python Programming questions
- What is printed? python print(0.1 3 == 0.30000000000000004, 0.1 3 - 0.3 == 5.551115123125783e-17, 0.3 - 0.1 3 == -5.551115123125783e-17)
- What is printed? python print(len('ab' + 'c' 0), 'ab'[1:][0] 2, ('ab' 2)[::3])
- What is printed? python print(int(' 3 ') + 1, int('3n') 2, float(' 2.5t') 2)
- What is printed? python print(len('é'.encode('utf-8').decode('latin-1')), 'é'.encode('utf-8').decode('latin-1'))
- What is printed? python print(sum(1 for c in 'Mississippi' if c in 'aeiouAEIOU'), 'Mississippi'.lower().count('s')…
- What is printed? python print([] == [] or 1 / 0, [] and 1 / 0, 0 or 1 and 2)