← 返回 microsoft 的题目列表Python Data Processing Question
类型:online_judge
Please write a Python function that takes a list of dictionaries as input. Each dictionary contains information about an employee, such as name, age, and department. The function should return the average age of employees in each department. Provide the function signature, complete solution, test cases, and data scale explanation.
Example: Input: [ {'name': 'Alice', 'age': 30, 'department': 'HR'}, {'name': 'Bob', 'age': 24, 'department': 'Engineering'}, {'name': 'Charlie', 'age': 32, 'department': 'HR'}, {'name': 'David', 'age': 28, 'department': 'Engineering'} ]
Output: {'HR': 31.0, 'Engineering': 26.0}
Example
Input
[{'name': 'Alice', 'age': 30, 'department': 'HR'}, {'name': 'Bob', 'age': 24, 'department': 'Engineering'}, {'name': 'Charlie', 'age': 32, 'department': 'HR'}, {'name': 'David', 'age': 28, 'department': 'Engineering'}]