ProgrammingVery hardTCS NQT · Accenture
What is printed?
What is printed?
print('%(a)s-%(b)05.1f' % {'a': 'x', 'b': 3.14159})- A. x-3.1
- B. x-003.1
- C. x-0003.1
- D. x-03.14159
Correct answer: B. x-003.1
%05.1f formats 3.14159 with one decimal place, giving 3.1, and pads it with zeros to width five to give 003.1. The mapping key a is looked up by the name in parentheses.
More Python Programming questions
- What is printed? python s = 'Ünïcödé' print(len(s), len(s.encode()), s.upper() == 'ÜNÏCÖDÉ')
- What is printed? python print(int('10', 2), int('0o17', 0), int('17', 8), int('0xff', 16))
- What is printed? python x = 0xDEAD print(x >> 8 & 0xFF, (x >> 8) & 0xF, hex(x & -x))
- What is printed? python print(sorted([-3, 2, -1, 4], key=lambda v: (abs(v) % 3, v)))
- What is printed? python print(f'{1234.5:,.2f}', f'{0.000123:.2e}', f'{-0.0:+.1f}', f'{0x123456:x}')
- What is printed? python print(int('٠٠٢٩') + 1, '٢٩'.isdigit())