Predict the output
A like counter is split over 4 sub-keys. What's the total?
sub_counts = {
"likes#0": 250, "likes#1": 248,
"likes#2": 255, "likes#3": 247,
}
print(sum(sub_counts.values()))Hint 1 of 1
Add the four values.
Choose an answer, then open Show answer below to check it.
Show answer
Answer: A 1000
Correct. Reads sum the sub-keys; writes spread over 4 places.
Splitting one hot counter into N sub-keys spreads its writes across N places. Reading the total costs a sum of N values, which here gives 1,000.
Why not the others?
- B
255. That's one sub-key. - C
250. Sum all four. - D
4. That's the number of sub-keys.