ProgrammingHardProduct-company MCQ pattern
What is printed?
What is printed?
print('%x' % -255, '%o' % 8, '%e' % 0.0, '%.0e' % 12345)- A. -fe 10 0.000000e+00 1e+04
- B. -ff 10 0.000000e+00 1.2e+04
- C. -ff 10 0.000000e+00 1e+04
- D. -ff 8 0.000000e+00 1e+04
Correct answer: C. -ff 10 0.000000e+00 1e+04
%x of a negative number keeps the minus sign, giving -ff rather than a two's complement form. %o of 8 is 10 in octal, and %.0e of 12345 rounds to one digit, 1e+04.
More Python Programming questions
- What is printed? python print(5 & 6 | 1, 5 & (6 | 1), 5 ^ 6 & 1, 1 | 2 ^ 3 & 4)
- What is printed? python print(-1 >> 1, -1 << 2, -5 >> 10, 5 >> -0 if False else 0)
- What is printed? python print(bin(-1 & 0b111), (-1) & 0xF == 15, -16 >> 2, -15 >> 2)
- What is printed? python print(''.join(sorted(set('mississippi'))), ''.join(sorted('mississippi', key=lambda c: (-'mississippi'.count(c)…
- What is printed? python print(str(1.1 1.1), str(1.21), 1.1 1.1 == 1.21, abs(1.1 1.1 - 1.21) < 1e-12)
- What is printed? python print(10 2 == 100.0, 2 0.5 2 == 2 0.25, pow(4, 0.5))