225k views
3 votes
Complete the function to return the specified employee's salary. You can assume that the employee's name occurs exactly once in the dictionary.

a)' getEmployeeSalary(employee_name)'

b)' retrieveEmployeeSalary(employee)'

c)' findEmployeeSalary(name)'

d) 'salaryOfEmployee(employee)'

1 Answer

3 votes

Final answer:

The most appropriate function name to complete the task of returning the specified employee's salary is 'retrieveEmployeeSalary(employee)'.

Step-by-step explanation:

The most appropriate function name to complete the task of returning the specified employee's salary is b) 'retrieveEmployeeSalary(employee)'. This function clearly indicates its purpose, which is to retrieve the salary information for a given employee. It is important to choose a function name that is descriptive and easy to understand.

Here's an example of how the function could be implemented:

def retrieveEmployeeSalary(employee):
return employee['salary']

# Usage:
employee = {'name': 'John Doe', 'salary': 50000}
salary = retrieveEmployeeSalary(employee)
print(salary)

In this example, the function takes an employee dictionary as an argument and returns the value for the 'salary' key. The function could then be called with the employee dictionary as an argument to retrieve the salary.

User Dvo
by
7.0k points