Answered step by step
Verified Expert Solution
Question
1 Approved Answer
in Python In this part of the assignment, you will write a function find.employee), which takes three arguments, in this order . employees: A list
in Python
In this part of the assignment, you will write a function find.employee), which takes three arguments, in this order . employees: A list of lists, in which each sub-list contains information about one particular employee Inside each sub-list we always find five tuples, wherein each tuple has two values: the first value is a field name, and the second value is the value of that field. The fields available are listed below. Note that although the five tuples will always exist, their order inside the sub-list may differ from employee to employee o 'Name: this string is the employee's name o 'Age': this integer is the employee's age o 'Salary: this integer is the employee's salary o 'Experience': this integer is the years of experience the employee has o 'Level':this integer is the employee's rank An example employees list containing the information about two employees is given below employees = [ ('Name,Tom'),'Age, 21),Salary',1000)(Experience',1),'Level',1) ('Experience', 2), 'Age',22)Name,'Sam),Salary' 2500),Level',3) . search.field: this is the particular field you are looking for . search.value: this is the desired value of a field you are looking for The function searches the employees list and returns a list of employee names whose search.field's value is equal to search.value. For example, if search.fieldLevel' and search.value - 2, the function would return a list of employee names whose Level is exactly 2 In brief, the function executes the following algorithm create an empty list (e.g, result) to store the names of employees we will return for each employee in the list of employees 1. using a for-loop, search the list of tuples of this employee to find the employee' s name (hint: have an if-statement look at index 0 of each tuple to find the tuple that contains Name so that we can record the employee's name, which will be at index 1 of that particular tuple) 2. using a separate for-loop, search the list of tuples of this employee to find the tuple that the search field argument at index 0 2a. when we find that tuple, check if the value at index 1 of the tuple equals the search_value argument of the function 2b. if so, append the employee' s name to the result list return the result listStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started