← Quiz: Counting: all 10 questions
Quiz: Counting · Question 9 of 10
What does this print? (code)
What does this print?
count = sum(1 for x in range(7) for y in range(7) for z in range(7) if x + y + z == 6)
print(count)
- A.21
- B.28
- C.36
- D.84
Answer & explanation
Correct answer: 28
Stars and bars: C(6 + 2, 2) = C(8, 2) = 28 non-negative solutions.
Can you get the rest right without peeking?
Take the timed Quiz: Counting quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →