ProgrammingVery hardCodeforces-style · placement coding round
What is printed?
What is printed?
import math n = 10**16 - 1 print(math.isqrt(n), int(n ** 0.5))
- A. 100000000 100000000
- B. 99999999 99999999
- C. 99999999 100000000
- D. 100000000 99999999
Correct answer: C. 99999999 100000000
10^16 - 1 is too large for an exact float, so the float square root rounds up to 10^8. math.isqrt works on integers exactly and returns 99999999.
More Python Programming questions
- What is printed? python print(sorted([('b', 2), ('a', 2), ('c', 3)], key=lambda t: (-t[1], t[0])))
- What is printed? python def ok(s): def chk(l, r): while l < r: if s[l] != s[r]: return False l += 1 r -= 1 return True l, r = 0, len(s)…
- What is printed? python def removek(num, k): st = [] for d in num: while k and st and st[-1] > d: st.pop() k -= 1 st.append(d) st =…
- What is printed? python def divcount(a, k): cnt = {0: 1} s = 0 ans = 0 for x in a: s = (s + x) % k ans += cnt.get(s, 0) cnt[s] =…
- What is printed? python print(sorted(['b', 'A', 'a', 'B']), sorted(['b', 'A', 'a', 'B'], key=str.lower))
- What is printed? python print('a-b-c-d'.rsplit('-', 2), 'a-b-c-d'.split('-', 1))