ProgrammingVery hardTCS CodeVita · Infosys HackWithInfy
What is printed?
What is printed?
print(len(str(int('7' * 4300))))
try:
int('7' * 4301)
except ValueError:
print('no')- A. 4300 yes
- B. 4300 no
- C. 4300 4301
- D. 4301 no
Correct answer: B. 4300 no
The int-string limit applies to both directions. An int with 4300 digits converts fine, so the first line is 4300. A 4301-digit decimal string raises ValueError when parsed.
More Python Programming questions
- What is printed? python print(round(0.25, 1), round(0.35, 1), round(2.5), round(-0.5))
- What is printed? python d = {'a': 1, 'b': 2} d['a'] = 3 d.pop('a') d['a'] = 4 print(list(d.items()))
- What is printed? python print({k % 4: k k for k in range(9, -1, -1)})
- What is printed? python print(sum([0.1] 10) == 1.0, 0.1 3 == 0.3)
- What is printed? python import heapq iv = sorted([(0, 30), (5, 10), (15, 20)]) h = [] for s, e in iv: if h and h[0] <= s…
- What is printed? python from collections import Counter a = [1, -1, 2, -2, 0] cnt = Counter({0: 1}) s = 0 ans = 0 for x in a: s += x ans…