ProgrammingHardGATE CS · Product-company placement
What is printed?
What is printed?
print(len(str(2**1000)), sum(int(d) for d in str(2**100)))
- A. 301 115
- B. 302 116
- C. 302 115
- D. 303 115
Correct answer: C. 302 115
2 to the power 1000 has floor(1000 * log10(2)) + 1 = 302 digits, and the digit sum of 2 to the power 100 is 115.
More Python Programming questions
- What is printed? python import math print(math.gcd(0, -6), math.lcm(4, 6), -7 % -3, math.lcm(0, 5))
- What is printed? python x = 6 print(x & (x - 1), x & -x, (x ^ (x >> 1)) & 1, x.bitlength(), (-x).bitlength())
- What is printed? python print(bin(10 ^ 6), 10 ^ 6 ^ 6, 3 ^ 5 ^ 3 ^ 5, ~-1, -~1)
- What is printed? python a = 1 if 3 > 2 else 0 print(a << 3 | 1, a << (3 | 1), 2 + 3 4 2 // 8 % 5)
- What is printed? python print(1 < 2 < 3 != 4, (1 < 2) < 3, 2 -1, 2 0.5 2)
- What is printed? python print(int(1e22) == 1022, int(1e23) == 1023, 1e23 == 1023, float(1023) == 1e23)