ProgrammingHardTCS NQT · Wipro pattern
What is printed?
What is printed?
print(format(1234567.891, ',.2f'), format(0.000123, 'e'), format(12, '>5'), format(3, '03'))
- A. 1,234,567.89 1.230000e-04 12 003
- B. 1,234,567.89 1.23e-04 12 003
- C. 1,234,567.89 1.230000e-04 12 3
- D. 1,234,567.8 1.230000e-04 12 003
Correct answer: A. 1,234,567.89 1.230000e-04 12 003
The comma flag groups thousands and .2f rounds to two decimals. The e format uses six decimals by default, and the > width 5 pads 12 with three spaces. A width of 03 pads the integer 3 with a leading zero.
More Python Programming questions
- What is printed? python print((1 + 2j) (3 - 1j), abs(3 + 4j), (1 + 2j).conjugate())
- What is printed? python print(list(zip([1, 2, 3], 'ab')), list(zip('ab', [1, 2, 3], [True])), len(list(zip())))
- What is printed? python try: list(zip([1, 2], [3], strict=True)) except ValueError: print('length mismatch') print(list(zip([1, 2], [3])))
- What is printed? python print([f'{i}{ch}' for i, ch in enumerate('ab', 1)])
- What is printed? python from itertools import groupby print([(k, len(list(g))) for k, g in groupby('aabbaa')])
- What is printed? python print('a,b'.split(',', -1), 'a,b,c'.split(',', 0), 'a b c'.split(maxsplit=1))