ProgrammingHardProduct-company MCQ pattern
What is printed?
What is printed?
print(f'{12.0:g}', f'{12.5:g}', f'{0.00001234:g}', f'{123456789:g}', f'{1.5e300:g}')- A. 12 12.5 1.234e-05 1.23457e+08 1.5e+300
- B. 12.0 12.5 1.234e-05 1.23457e+08 1.5e+300
- C. 12 12.5 0.00001234 123456789 1.5e+300
- D. 12 12.5 1.234e-05 1.23457e+08 1500e+297
Correct answer: A. 12 12.5 1.234e-05 1.23457e+08 1.5e+300
The g format drops trailing zeros, so 12.0 shows as 12. Integers passed to g are converted to float first, so 123456789 keeps six significant digits as 1.23457e+08.
More Python Programming questions
- What is printed? python print(10 18 10 18 // 10 35, 2 64 // 2 32, 2 64 % 2 32)
- What is printed? python x = 1 << 200 print(x.bitlength(), len(str(x)), x % 1000, (x >> 190) & 0xFF)
- What is printed? python print(f'{210:,}', f'{210:x}', f'{210:b}', f'{-210:>8}'.strip())
- What is printed? python print(str(round(2.5)), str(round(3.5)), round(2.5 + 0.0001), round(-2.5 - 0.0001))
- What is printed? python s = 'ab' 2 + 'c' print(s.endswith('bc'), s.startswith('ab', 2), s.find('ab', 1), s.count('ab'))
- What is printed? python print(len(''.join(str(i) for i in range(1, 11))), ''.join(str(i) for i in range(1, 11))[-3:], sum(len(str(i)) for…