ProgrammingHardTCS CodeVita · Infosys HackWithInfy
What is printed?
What is printed?
print(int('0' * 5 + '7') + int(' -3 '), len(str(int('9' * 50) + 1)))- A. 10 50
- B. 4 51
- C. 4 50
- D. 3 51
Correct answer: B. 4 51
int() accepts leading zeros in base 10 and surrounding whitespace. 7 + (-3) = 4. The number 99...9 (50 nines) plus 1 is 10^50, which has 51 digits.
More Python Programming questions
- What is printed? python import math print(math.isqrt(99), math.isqrt(100), round(2.5), round(3.5))
- What is printed? python import itertools print(list(itertools.accumulate([3, 1, 4, 1, 5], max))[-1], list(itertools.accumulate([3, 1, 4]…
- What is printed? python import heapq print(heapq.heappop([]) if False else 'ok', heapq.nlargest(1, []))
- What is the time complexity of building a heap from n items with heapq.heapify, compared with pushing the n items one by one with…
- What is printed? python x = 255 print(x.bitlength(), bin(x).count('1'), (x & -x), (x - 1) & x)
- What is printed? python print(-7 // 2, 7 // -2, -7 % 2, 7 % -2)