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))
  1. A. 25 6
  2. B. 24 6
  3. C. 24 5
  4. 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

Exams that ask this topic