← Quiz: Graph Theory Workshop: all 14 questions
Quiz: Graph Theory Workshop · Question 2 of 14
What does this print? (code)
What does this print?
seq = [3, 3, 2, 2, 2]
d = seq.pop(0)
for i in range(d):
seq[i] -= 1
print(sorted(seq, reverse=True))
- A.[3, 2, 2, 2]
- B.[2, 2, 1, 1]
- C.[2, 1, 1, 1]
- D.[3, 3, 2, 2]
Answer & explanation
Correct answer: [2, 2, 1, 1]
Removing the 3 and subtracting 1 from the next three degrees gives [2, 1, 1, 2], sorted as [2, 2, 1, 1].
Can you get the rest right without peeking?
Take the timed Quiz: Graph Theory Workshop quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →