ProgrammingHardTCS NQT · Infosys
What is printed?
What is printed?
print('%x' % 255, '%X' % 255, '%#o' % 8, '%+d' % 0)- A. ff FF 010 0
- B. ff FF 0o11 0
- C. ff fe 0o10 0
- D. ff FF 0o10 +0
Correct answer: D. ff FF 0o10 +0
%x gives lowercase hex and %X uppercase. The # flag adds the 0o prefix for octal, and the + flag shows a sign even for zero.
More Python Programming questions
- What is printed? python print(float('1e-7'), 0.000001, 1e-6 == 0.000001, 123456789012345678.0)
- What is printed? python print(round(0.5 + 1), round(-0.5 - 1), round(2.5 - 0.0001))
- What is printed? python print(0.1 + 0.2 - 0.3, 0.3 - 0.1 - 0.2, 1 / 49 49, 1 / 10 10)
- What is printed? python import bisect a = [10, 9, 2, 5, 3, 7, 101, 18] tails = [] for x in a: i = bisect.bisectleft(tails, x) if i ==…
- What is printed? python from itertools import product print(list(product('ab', repeat=2)), list(product([0, 1], 'x')))
- What is printed? python d = {'pen': 3, 'cap': 5, 'ink': 3, 'box': 1} print(sorted(d.items(), key=lambda kv: (-kv[1], kv[0]))[:3])