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

Quiz: Control Unit Design · Question 8 of 10

What does this print? (code)

What does this print?

from math import ceil, log2
groups = [4, 9, 2]
print([ceil(log2(g + 1)) for g in groups], sum(groups))
  1. A.[2, 3, 1] 15
  2. B.[3, 4, 2] 15
  3. C.[3, 4, 2] 16
  4. D.[2, 4, 2] 15
Answer & explanation

Correct answer: [3, 4, 2] 15

4 + 1 = 5 codes need 3 bits; 9 + 1 = 10 need 4; 2 + 1 = 3 need 2.

Can you get the rest right without peeking?

Take the timed Quiz: Control Unit Design quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →