ProgrammingHardTCS NQT · Infosys
What is printed?
What is printed?
print('%s|%s' % ('a', 'b'), 'ok', '%5.1f%%' % 99.55)- A. a|b ok 99.3%
- B. a|b ok 99.6%
- C. a|b ok 99.5%
- D. a|b no 99.5%
Correct answer: C. a|b ok 99.5%
Two %s fields print a and b, separated by a bar. 99.55 is stored a little below the midpoint, so %5.1f gives 99.5, padded to width five and followed by a literal percent sign.
More Python Programming questions
- What is printed? python print(len(set('aabbcc')), sorted(set('cba')), 'abc'.index('b') + 'abc'.count('b'))
- What is printed? python print(1000000 1000000 == 1012, 0.1 0.1 100 == 1, round(0.1 0.1 100, 10) == 1.0, 2 0.5 == 2 (1 / 2))
- What is printed? python print(sum(range(0, 101, 5)), len(range(0, 101, 5)))
- What is printed? python print(bin(37)[2:].zfill(8), int('100101', 2) == 37)
- What is printed? python import heapq h = [] for x in [5, 2, 8]: heapq.heappush(h, x) print(heapq.heappop(h), heapq.heappop(h), h)
- What is printed? python print(sorted([3, 1, 2], key=lambda x: -x)[0], max([3, 1, 2], key=lambda x: -x))