ProgrammingHardProduct-company MCQ pattern
What is printed?
What is printed?
print('%s and %s' % ('A', 'B'), '%(x)d-%(x)05.1f' % {'x': 3}, '%%%d' % 5)- A. A and B 3-003.0 %6
- B. A and B 3-003 %5
- C. A and B 3-003.0 %5
- D. A and B 3-0003.0 %5
Correct answer: C. A and B 3-003.0 %5
%(x)05.1f pads to width 5 with zeros, giving 003.0. A doubled %% prints a literal percent sign, so the last value is '%5'.
More Python Programming questions
- What is printed? python print(1 / 2 + 1 // 2 + 1 % 2, 1 / 2 2 == 1, 3 1 / 2 == 3 (1 / 2))
- What is printed? python print(0x10 + 0o10 + 0b10, 10 + 0x1, 1e1 + 1, 1j 1j)
- What is printed? python print(max(-0.0, 0), min(0, -0.0), -0.0 + 0, 0 - 0.0)
- What is printed? python a = 10 b = 3 print(a / b b == a, a // b b + a % b == a, a % b / b == (a / b) % 1)
- What is printed? python print(7 % 3 2, (7 % 3) 2, -7 % 3 2, 2 3 2 % 4)
- What is printed? python print(len(' a b '.split()), len(' a b '.split(' ')), len('anbn'.splitlines()), len('anbn'.split('n')))