ProgrammingHardTCS NQT · Infosys
What is printed?
What is printed?
print('{:^6}'.format('ab'), '{:*<4}'.format(1), '{:>3}|{:<3}|'.format('a', 'b'))- A. ab 1*** a|b |
- B. ab 2*** a|b |
- C. ab 1*** a|c |
- D. ac 1*** a|b |
Correct answer: A. ab 1*** a|b |
The centre spec pads the two-character ab to six with two spaces on each side. * fill with < pads 1 on the right, and each field in the last string gets its own alignment.
More Python Programming questions
- What is printed? python print('a' < 'b' < 'c', 'b' > 'a' and 'b' > 'c')
- What is printed? python print(len([range(3), 'ab']), ['ab', [1]], {{'a': 1}, 'a': 2})
- What is printed? python print(hash(()) == hash(()), (1, 2) < (1, 2, 0), 'b' 2 > 'ab' 2, (1, 'b') < (1, 'a'))
- What is printed? python print(sorted(['b', 'B', 'a'], key=lambda s: (s.lower(), s)))
- What is printed? python from math import prod print(prod([2, 3, 4]), prod([]), prod([0.5, 4]), prod(range(1, 4), start=10))
- What is printed? python print(2 -1 2 1, 2 -(1 2) 1, (2 -1) (2 1))