products with product names as keys and prices as values.sort_direction that can be either 'asc' or 'desc'.sort_direction.products with product names as keys and prices as values.sort_direction that can be either 'asc' or 'desc'.sort_direction.products with these exact entries: 'apple': 120, 'banana': 80, 'cherry': 150, 'date': 100.Use curly braces {} to create a dictionary with keys and values separated by colons.
sort_direction and set it to the string 'asc' to sort prices in ascending order.Assign the string 'asc' to the variable sort_direction.
sorted_products that sorts the items of products by price. Use sort_direction to decide ascending or descending order. Use sorted(products.items(), key=lambda item: item[1], reverse=sort_direction == 'desc').Use the sorted() function with key=lambda item: item[1] to sort by price. Set reverse=True if sort_direction is 'desc'.
sorted_products list to show the product names and prices in the chosen order using print(sorted_products).Use print() to show the sorted list.
What does the direction=asc parameter do in a REST API request?
Which of the following is the correct way to specify descending sort direction in a REST API URL query?
https://api.example.com/items?sort=price&_____
Given this REST API response sorted by rating in descending order, what is the first item's rating?
GET https://api.example.com/movies?sort=rating&direction=desc
Response:
[
{"title": "Movie A", "rating": 9.5},
{"title": "Movie B", "rating": 8.7},
{"title": "Movie C", "rating": 7.9}
]Identify the error in this REST API request URL that tries to sort users by age in descending order:
https://api.example.com/users?sort=age&direction=descending
You want to get a list of products sorted by price ascending, but only those with price greater than 100. Which query parameters correctly combine sorting and filtering?
Pass the test and this pattern moves unknown