How to Use List Sorting with Custom Key Function
Output: Original Words: [‘apple’, ‘banana’, ‘orange’, ‘grape’]Sorted Words by Length: [‘apple’, ‘grape’, ‘banana’, ‘orange’]
Output: Original Words: [‘apple’, ‘banana’, ‘orange’, ‘grape’]Sorted Words by Length: [‘apple’, ‘grape’, ‘banana’, ‘orange’]
Output: Numbers: [1, 2, 3, 4, 5]Standard Deviation: 1.58
Output: Original Data:{‘name’: ‘John’, ‘age’: 30, ‘city’: ‘New York’}Formatted JSON:{“name”: “John”,“age”: 30,“city”: “New York”}
Output: Main String: ‘Python is versatile’Contains Substring: True
Output: Queue: deque([2, 3, 4, 5, 6])Dequeued Item: 1
Output: Original String: ‘ Python is fun! ‘Trimmed String: ‘Python is fun!’
Output: 2 raised to the power of 3 is 8.0
Output: Numbers: [1, 2, 3, 4, 5, 6, 7, 8, 9]Even Numbers: [2, 4, 6, 8]
Output: Sentence: Python programming is amazingLongest Word: programming