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

single

Task: Sorting Data

Glissez pour afficher le menu

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.

Tâche

Glissez pour commencer à coder

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.

Solution

Switch to desktopPassez à un bureau pour une pratique réelleContinuez d'où vous êtes en utilisant l'une des options ci-dessous
Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 2. Chapitre 3
single

single

Demandez à l'IA

expand

Demandez à l'IA

ChatGPT

Posez n'importe quelle question ou essayez l'une des questions suggérées pour commencer notre discussion

some-alt