Predict the output
Six partitions, a group of four consumers. With an even assignment, how many partitions does the busiest consumer own?
partitions, consumers = 6, 4
busiest = -(-partitions // consumers)
print(busiest)Hint 1 of 1
Ceiling of 6 / 4.
Choose an answer, then open Show answer below to check it.
Show answer
Answer: A 2
Correct. 6 over 4 means two consumers own 2 and two own 1.
Within a group, each partition goes to exactly one consumer. Six partitions over four consumers means two get 2 each and two get 1; the code works out the ceiling of 6/4.
Why not the others?
- B
1. Six partitions can't fit one per consumer with four consumers. - C
6. Partitions are shared within a group. - D
1.5. Partitions aren't split; the code uses ceiling division.