编程题:有一个列表,该列表中存储了某个公司的职员的信息, 13 请编写程序找出该公司中薪水最高的职员,并打印出他的姓名。(30分) 14 请将程序写入到下面的second O)函数中,写在函数体之外无效。 15 employees -[ 16 'name':'张无忌','department':"研发部', ' salary':9896.45}, 17 'name':'杨过',"department':‘研发部','salary':28136.39], 18 F'name ':'小龙女!,'depar tment':'市场部','salary':7424.28}, 19 {'name':"乔峰!,' department!:"研发部','salary ':57636.89], 20 'name ':'阿碧',department':"市场部',' salary':4748.79], 21 ] 22 1I111 second0 Packages TOD0Python Console!ProblemsTerminalServices 24
时间: 2023-08-06 09:21:53 浏览: 113
面试编程题
可以使用以下代码实现:
```python
def secondO():
employees = [
{'name': '张无忌', 'department': '研发部', 'salary': 9896.45},
{'name': '杨过', 'department': '研发部', 'salary': 28136.39},
{'name': '小龙女', 'department': '市场部', 'salary': 7424.28},
{'name': '乔峰', 'department': '研发部', 'salary': 57636.89},
{'name': '阿碧', 'department': '市场部', 'salary': 4748.79}
]
max_salary = 0
max_name = ''
for employee in employees:
if employee['salary'] > max_salary:
max_salary = employee['salary']
max_name = employee['name']
print('薪水最高的职员是:{}'.format(max_name))
secondO()
```
输出结果为:
```
薪水最高的职员是:乔峰
```
阅读全文