How can numbers be sorted from largest to smallest in Python?
You can use the sorted() function to sort a list of numbers from largest to smallest. By default, the sorted() function sorts the list elements in ascending order, but you can achieve descending order by using the reverse=True parameter.
Here is an example code:
numbers = [5, 2, 8, 1, 9]
sorted_numbers = sorted(numbers, reverse=True)
print(sorted_numbers)
The output is: [9, 8, 5, 2, 1]