← Quiz: Closures and Warshall's Algorithm: all 10 questions
Quiz: Closures and Warshall's Algorithm · Question 8 of 10
What does this print? (code)
What does this print?
W = [[0, 1, 0], [0, 0, 1], [0, 0, 0]]
n = 3
for k in range(n):
for i in range(n):
for j in range(n):
W[i][j] = W[i][j] or (W[i][k] and W[k][j])
print(sum(map(sum, W)))
- A.2
- B.3
- C.4
- D.9
Answer & explanation
Correct answer: 3
The chain 1 → 2 → 3 adds only (1, 3), so there are 3 ones.
Can you get the rest right without peeking?
Take the timed Quiz: Closures and Warshall's Algorithm quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →