0
0
Pythonprogramming~15 mins

sorted() function in Python - Mini Project: Build & Apply

Choose your learning style9 modes available
Sorting a List of Fruits Alphabetically
๐Ÿ“– Scenario: You have a list of fruits that you want to organize alphabetically, just like arranging books on a shelf in order.
๐ŸŽฏ Goal: Learn how to use the sorted() function in Python to sort a list of items alphabetically.
๐Ÿ“‹ What You'll Learn
Create a list called fruits with the exact items: 'banana', 'apple', 'cherry', 'date'
Create a variable called sorted_fruits to store the sorted list
Use the sorted() function to sort the fruits list
Print the sorted_fruits list to show the result
๐Ÿ’ก Why This Matters
๐ŸŒ Real World
Sorting lists is useful when you want to organize items like names, products, or any data alphabetically or by some order.
๐Ÿ’ผ Career
Many jobs require sorting data to make it easier to search, analyze, or display neatly, such as in data entry, programming, or report generation.
Progress0 / 4 steps
1
Create the list of fruits
Create a list called fruits with these exact items in this order: 'banana', 'apple', 'cherry', 'date'
Python
Need a hint?

Use square brackets [] to create a list and separate items with commas.

2
Prepare a variable for the sorted list
Create a variable called sorted_fruits to hold the sorted list of fruits
Python
Need a hint?

Just create an empty list variable for now; we will fill it next.

3
Sort the list using sorted()
Use the sorted() function to sort the fruits list and assign the result to sorted_fruits
Python
Need a hint?

Call sorted(fruits) and assign it to sorted_fruits.

4
Print the sorted list
Print the sorted_fruits list to display the sorted fruits
Python
Need a hint?

Use print(sorted_fruits) to show the sorted list.