ProgrammingHardTCS NQT · Wipro pattern
What is printed?
What is printed?
print(len('é'), len('é'.encode()), len(f'{"é":>3}'), len(str(0.1 + 0.2)))- A. 1 2 1 19
- B. 1 2 3 17
- C. 1 3 3 19
- D. 1 2 3 19
Correct answer: D. 1 2 3 19
é is one code point but two UTF-8 bytes. The f-string pads it to width three, and str(0.1 + 0.2) is '0.30000000000000004', which has 19 characters.
More Python Programming questions
- What is printed? python print('%-6s|' % 'ab', '%6.2f|' % 3.14159, '%+.1e' % 12345.6789)
- 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()))))