ProgrammingModerateTCS NQT · Infosys
What is printed?
What is printed?
print(int('12' '34') + 1, '%d' % 3.9, '%i' % -3.9, '%+d' % 0)- A. 1235 3 -4 +0
- B. 1234 3 -3 +0
- C. 1235 3 -3 +0
- D. 1235 4 -3 +0
Correct answer: C. 1235 3 -3 +0
Adjacent string literals join before int() runs, so int('1234') + 1 is 1235. The %d and %i formats truncate floats toward zero, and %+d always shows the sign.
More Python Programming questions
- Which approach removes duplicates from a list while keeping the first-seen order, in O(n) average time?
- Which statement about sorting 10^6 floats with sorted() in CPython is correct?
- Which operation is O(1) amortised in CPython?
- What is printed? python from functools import lrucache @lrucache(maxsize=None) def f(a, b=0): return a + b f(1, 2) f(1, b=2) f(1)…
- What is printed? python from collections import OrderedDict od = OrderedDict() for k in ['a', 'b', 'c']: od[k] = ord(k) od.movetoend('a')…
- What is printed? python b = [3, 1, 2] a = b.sort() c = sorted(b, reverse=True) print(a, b, c)