ProgrammingModerateTCS NQT · Accenture
What is printed?
What is printed?
def zeros(n):
c = 0
while n:
n //= 5
c += n
return c
print(zeros(100), zeros(25))- A. 25 6
- B. 24 6
- C. 24 5
- D. 20 6
Correct answer: B. 24 6
Trailing zeros come from factors of 5, and the loop adds n // 5 + n // 25 + and so on. The count for 100 is 24, and for 25 it is 6.
More Python Programming questions
- What is printed? python def mincut(s): n = len(s) pal = [[False] n for in range(n)] for i in range(n - 1, -1, -1): for j in range(i, n)…
- What is printed? python def triecount(words, pref): root = {} for w in words: node = root for ch in w: node = node.setdefault(ch, {})…
- What is printed? python M = 109 + 7 N = 10 fact = [1] (N + 1) for i in range(1, N + 1): fact[i] = fact[i - 1] i % M def nCr(n, r): return…
- What is printed? python def summin(a): MOD = 109 + 7 st = [] total = 0 cur = 0 for x in a: cnt = 1 while st and st[-1][0] >= x: v, c =…
- What is printed? python print(6 & 3 == 2, 5 | 2 == 7)
- What is printed? python import heapq def medians(xs): lo, hi = [], [] out = [] for x in xs: heapq.heappush(lo, -x) heapq.heappush(hi…