ProgrammingHardTCS NQT · Wipro pattern
What is printed?
What is printed?
print(int(str(10**20 + 1)[-1]) + len(str(10**20)), 10**20 + 1 == int(str(10**20 + 1)))
- A. 22 True
- B. 21 True
- C. 22 False
- D. 21 False
Correct answer: A. 22 True
The last digit of 10**20 + 1 is 1, and str(10**20) has 21 characters, so the sum is 22. Converting the string back gives the same integer, so the comparison is True.
More Python Programming questions
- What is printed? python print(divmod(7.5, 2), divmod(-7.5, 2), 7.5 % -2, -7.5 // -2)
- What is printed? python print(-7 % 4, -7 % -4, 7 % -4, (-7) % 4 == -7 % 4)
- What is printed? python def edit(a, b): dp = [[0] (len(b) + 1) for in range(len(a) + 1)] for i in range(len(a) + 1): for j in range(len(b)…
- What is printed? python def lcs(a, b): dp = [[0] (len(b) + 1) for in range(len(a) + 1)] for i in range(1, len(a) + 1): for j in range(1…
- What is printed? python from itertools import accumulate a = [2, -1, 3] P = list(accumulate(a, initial=0)) print(P, P[3] - P[1])
- What is printed? python from itertools import combinations print(sum(1 for r in range(5) for c in combinations([1, 2, 3, 4], r) if sum(c)…