Find the smallest number in the list.
Example:
Input: [3, 1, 4, 2]
Output: 1
Find the shortest word.
Example:
Input: ["apple", "banana", "kiwi", "pear"]
Output: "kiwi"
Find the string with the smallest number of vowels.
Example:
Input: ["book", "sky", "quiet", "data"]
Output: "sky"
Hint: Use key=lambda word: count_vowels(word)
Find the dictionary with the smallest value.
Example:
Input: [{'a': 5}, {'a': 3}, {'a': 7}]
Output: {'a': 3}
Hint: key=lambda d: d['a']
Find the tuple with the smallest second element.
Example:
Input: [(1, 3), (2, 2), (3, 1)]
Output: (3, 1)
Find the largest number in the list.
Example:
Input: [7, 4, 9, 1]
Output: 9
Find the longest word.
Example:
Input: ["pen", "notebook", "eraser"]
Output: "notebook"
Find the name with the highest number of letters.
Example:
Input: ["Ann", "Robert", "Charlotte", "Mike"]
Output: "Charlotte"
Find the word with the most vowels.
Example:
Input: ["tree", "education", "sky", "road"]
Output: "education"
Find the person with the highest age.
Example:
Input: [{"name": "Alice", "age": 30}, {"name": "Bob", "age": 45}, {"name": "Tom", "age": 28}]
Output: {"name": "Bob", "age": 45}
Add 10 to each number.
Example:
Input: [1, 2, 3]
Output: [11, 12, 13]
Convert all words to uppercase.
Example:
Input: ["cat", "dog", "fish"]
Output: ["CAT", "DOG", "FISH"]
Get the lengths of each word.
Example:
Input: ["hi", "hello", "bye"]
Output: [2, 5, 3]
Square each number.
Example:
Input: [1, 4, 5]
Output: [1, 16, 25]
Extract names from a list of dictionaries.
Example:
Input: [{"name": "Alice"}, {"name": "Bob"}, {"name": "Carol"}]
Output: ["Alice", "Bob", "Carol"]
Filter out even numbers.
Example:
Input: [1, 2, 3, 4, 5]
Output: [1, 3, 5]
Keep words longer than 4 letters.
Example:
Input: ["hi", "hello", "world", "cat"]
Output: ["hello", "world"]
Keep numbers greater than 10.
Example:
Input: [5, 11, 20, 7, 10]
Output: [11, 20]
Filter names that start with "A".
Example:
Input: ["Alice", "Bob", "Anna", "Charlie"]
Output: ["Alice", "Anna"]
Keep words that contain the letter "e".
Example:
Input: ["dog", "elephant", "cat", "eagle"]
Output: ["elephant", "eagle"]
Use lambda to square a number.
Example:
Input: lambda x: x**2, input 5
Output: 25
Use lambda to return the last character of a string.
Example:
Input: lambda s: s[-1], input "apple"
Output: "e"
Sort a list of strings by their length using lambda.
Example:
Input: ["apple", "kiwi", "banana"]
Output: ["kiwi", "apple", "banana"]
Sort a list of tuples by the second value using lambda.
Example:
Input: [(1, 3), (2, 1), (3, 2)]
Output: [(2, 1), (3, 2), (1, 3)]
Use lambda to check if a number is even.
Example:
Input: lambda x: x % 2 == 0, input 4
Output: True