← 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))
- A.62
- B.10
- C.Z
- 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 →