Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Leer Task: Sorting Data | Lists, Loops And Functions
Python: For Beginners
Sectie 2. Hoofdstuk 3
single

single

Task: Sorting Data

Veeg om het menu te tonen

Now that you master closures, let's sort some data.

Sorting data is a key skill. Here's how to use sorted():

123
data = [5, 2, 8, 1] result = sorted(data) print(result) # Printing the result

In Python, the sorted() function returns a new list and doesn't modify the original. it's a pure function.

Taak

Veeg om te beginnen met coderen

We need you to sort the list numbers in ascending order and store the result in sorted_numbers.

  • Assign the sorted version of numbers to the variable sorted_numbers;
  • Use the sorted function to do this;
  • Print sorted_numbers.

Oplossing

Switch to desktopSchakel over naar desktop voor praktijkervaringGa verder vanaf waar je bent met een van de onderstaande opties
Was alles duidelijk?

Hoe kunnen we het verbeteren?

Bedankt voor je feedback!

Sectie 2. Hoofdstuk 3
single

single

Vraag AI

expand

Vraag AI

ChatGPT

Vraag wat u wilt of probeer een van de voorgestelde vragen om onze chat te starten.

some-alt