← Quiz: Caching and CDNs: all 10 questions
Quiz: Caching and CDNs · Question 7 of 10
What does this print? (code)
What does this print?
cache = {}
db = {"course:1": "Java"}
hits = misses = 0
for key in ["course:1", "course:1", "course:1"]:
if key in cache:
hits += 1
else:
misses += 1
cache[key] = db[key]
print(hits, misses)
- A.0 3
- B.3 0
- C.1 2
- D.2 1
Answer & explanation
Correct answer: 2 1
The first read misses and fills the cache; the next two are hits.
Can you get the rest right without peeking?
Take the timed Quiz: Caching and CDNs quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →