Question: [ 4 marks ] 5 . Lambda with Built - in Functions - Sorting: You have a list of tuples where each tuple contains the

[4 marks]
5. Lambda with Built-in Functions - Sorting: You have a list of tuples where each tuple contains the name of a product and its corresponding price. Use a lambda function as a key argument to the sorted() function to sort these products by price in ascending order. Print the sorted list.
products =[('apple',1.0),('banana',0.5),('cherry',1.5),('date',0.75)]
[4 marks]
6. Bonus: Lambda for Custom Sorting: Imagine you have a list of dictionaries where each dictionary contains information about a book, specifically its title and the year it was published. Write a lambda function to sort the list of books by year of publication, from the oldest to the newest. Print the sorted list.[6 marks]
[ 4 marks ] 5 . Lambda with Built - in Functions

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!