ProgrammingHardProduct-company MCQ pattern
What is printed?
What is printed?
print(f'{-5:+}', f'{5:+}', f'{3.0:g}', f'{1e6:g}', f'{1e-5:g}', f'{123456789.0:g}')- A. -5 +5 3.0 1000000 0.00001 123456789.0
- B. -5 +5 3 1e+06 1e-05 1.2346e+08
- C. -5 +5 3 1e+06 1e-05 1.23457e+08
- D. -5 +5 3 1e+6 1e-5 1.23457e+8
Correct answer: C. -5 +5 3 1e+06 1e-05 1.23457e+08
The g format drops trailing zeros and switches to scientific notation once the exponent reaches the precision (6 significant digits by default). The + sign flag shows a sign for positive numbers too.
More Python Programming questions
- What is printed? python print(f'{12345678:,}', f'{0.5:.0%}', f'{2.5:.0f}', f'{3.5:.0f}', f'{-0.4:.0f}')
- What is printed? python print(repr(1e16), repr(1e15 + 0.3), 1e16 == 1016, 1e16 + 1 == 1e16)
- What is printed? python print(10 -2, 10.0 -2, 1000 10, 2 -1 4)
- What is printed? python print(bool(0.0), bool(-0.0), bool(float('nan')), bool(' '), bool('0'), bool(0j))
- What is printed? python s1 = 'u00e9' s2 = 'eu0301' print(s1 == s2, len(s1), len(s2), len(s2.encode()), s2 == 'eu0301')
- What is printed? python print(len('héllo'.encode('utf-8')), len('héllo'.encode('utf-16')), len('héllo'))