🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Design a URL Shortener: all 10 questions

Quiz: Design a URL Shortener · Question 4 of 10

What does this print? (code)

What does this print?

def to_base62(n):
    a = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
    out = ""
    while n:
        n, r = divmod(n, 62)
        out = a[r] + out
    return out or "0"
print(to_base62(62))
  1. A.62
  2. B.10
  3. C.Z
  4. D.01
Answer & explanation

Correct answer: 10

62 = 1 × 62 + 0, so the digits are 1 and 0.

Can you get the rest right without peeking?

Take the timed Quiz: Design a URL Shortener quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →