ProgrammingVery hardGATE CS · Product-company placement

What is printed?

What is printed?
w = 7
print(f"{'x':>{w}}|{3.0:g}|{1e-5:.0e}|{0.5:.0%}|{-3:+d}|{12:08b}")
  1. A. x |3.0|1e-05|50%|-3|1100
  2. B. x|3|1e-05|50%|-3|00001100
  3. C. x|3|1e-5|50%|+-3|00001100
  4. D. x|3.0|0.00001|0.5%|-3|00001100

Correct answer: B. x|3|1e-05|50%|-3|00001100

Nested {w} sets the width to 7. :g drops trailing zeros, .0e gives one significant digit in exponent form, .0% multiplies by 100, + forces a sign (already '-'), and 08b pads binary to 8 digits.

More Python Programming questions

Exams that ask this topic