🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Python Lists: all 15 questions

Quiz: Python Lists · Question 15 of 15

What does this print? (code)

What does this print?

nums = [5, 2, 8]
nums.sort(reverse=True)
print(nums)
  1. A.[2, 5, 8]
  2. B.None
  3. C.[5, 2, 8]
  4. D.[8, 5, 2]
Answer & explanation

Correct answer: [8, 5, 2]

sort(reverse=True) sorts the list in place from largest to smallest.

Can you get the rest right without peeking?

Take the timed Quiz: Python Lists quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →