ProgrammingVery hardTCS NQT · Accenture
What is printed?
What is printed?
print('%-6s|' % 'ab', '%6.2f|' % 3.14159, '%+.1e' % 12345.6789)- A. ab | 3.15| +1.2e+04
- B. ab | 3.14| +1.2e+04
- C. ab | 3.14| +1.3e+04
- D. ab | 3.14| +1.2e+4
Correct answer: B. ab | 3.14| +1.2e+04
%-6s left-aligns ab in six columns, and %6.2f right-aligns 3.14 in six columns. The + flag with %e gives a signed value rounded to one decimal, which is +1.2e+04.
More Python Programming questions
- What is printed? python from decimal import Decimal, ROUNDHALFEVEN print(Decimal('2.5').quantize(Decimal('1'), rounding=ROUNDHALFEVEN)…
- What is printed? python x = 'a,b;c' print(x.split(',', 1), x.split(';')[0].split(','), [t for t in x.replace(';', ',').split(',') if t]…
- What is printed? python print(sorted(['10', '9', '100', '8'], key=len), sorted(['10', '9', '100', '8'], key=int))
- What is printed? python from math import isqrt print(isqrt(1030), isqrt(99), isqrt(1030 - 1))
- What is printed? python print(sum(1 for in range(105) if '7' in str()), len(str(sum(1 for in range(105) if '7' in str()))))
- What is printed? python print('%s' % (1,), '%s' % ((1,),), '%r' % ((1, 2),))