ProgrammingModerateTCS NQT · Infosys
What is printed?
What is printed?
print(int('-0b11', 0), int('0_1', 0) if False else 0, int('1000'), int(' 0010 '))- A. -3 0 1000 11
- B. -3 0 100 10
- C. -3 0 1000 10
- D. -2 0 1000 10
Correct answer: C. -3 0 1000 10
Base 0 reads the 0b prefix and the minus sign, giving -3. Surrounding whitespace is ignored, and leading zeros are allowed when converting a string with int().
More Python Programming questions
- What is printed? python print(abs(-263) == 263, abs(-0.0) == 0.0, abs(-2.5) // 1, -2.5 // 1 -1)
- What is printed on the second line? python import math print(math.gcd(12, 18, 24), math.gcd(), math.lcm(), math.lcm(4, 0, 9))…
- Which line is printed? python print(divmod(270, 106)[1] == 270 % 106, divmod(-270, 106)[1] == (-270) % 106, (-270) // 106 == -(270 // 106)…
- What is printed? python from collections import Counter print(Counter('mississippi').mostcommon(3))
- What is printed? python from functools import lrucache @lrucache(None) def total(xs): return sum(xs) try: print(total([1, 2, 3])) except…
- What is printed? python import bisect print(bisect.bisectleft(range(100), True, key=lambda x: x x >= 50))