ProgrammingModerateTCS NQT · Wipro pattern
What is printed?
What is printed?
print('%.3s|%5.1s|' % ('abcdef', 'xyz'))- A. abc| x|
- B. abcdef| x|
- C. abc| xy|
- D. ab| x|
Correct answer: A. abc| x|
A precision on %s truncates the string, so .3 keeps abc. The width of 5 with precision 1 keeps only x and right-aligns it in five columns.
More Python Programming questions
- What is printed? python print('straße'.casefold() == 'strasse', 'straße'.lower() == 'strasse', 'Straße'.casefold())
- What is printed? python print('x'.removeprefix('xx'), 'hello'.removesuffix('llo'), 'abc'.removeprefix(''))
- What is printed? python print(str.maketrans('ab', 'xy', 'c'), 'abcabc'.translate(str.maketrans('ab', 'xy', 'c')))
- What is printed? python print(sorted(['10', '9', '100', '2']), sorted(map(int, ['10', '9', '100', '2'])))
- What is printed? python print(-7 // -2, 7 // -2 -2 + 7 % -2)
- What is printed? python print(round(-2.5), round(-3.5), round(7, -1), round(15, -1), round(25, -1))