Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

t Solve it phyton please. In this homework assignment, you are supposed to implement an office directory that contains phone and room numbers of multiple

timage text in transcribed

image text in transcribed

image text in transcribed

Solve it phyton please.

In this homework assignment, you are supposed to implement an office directory that contains phone and room numbers of multiple employees. For each employee, you will store a record, in which you keep 1. The name string 2. The phone number integer, and 3. The room number (string) This information will be added to the office directory when an employee is hired and remains unchanged until the employee is filled or quits the job. Thus, in your implementation, you MUST define a tuple to keep Information of each employee and you MUST define a list of tuples to keep all employees Your implementation must have at least the following four functions whose details are given below: 1. Add an employee 2. Remove an employee 3. Display all employees 4. Show Information about an employee ADD AN EMPLOYEE This function adds an employee to the office directory. The name, the phone number, and the room number of the employee are specified as parameters. In this office directory, names are unique. The names are also case insensitive that is "cigdem gundur" and "Cidem gulduz" should be considered as the same. Thus, if the user attempts to add an employee with an already existing name the function does not add the employee to the directory and displays a warning message. Otherwise, it performs the action. (See the example test program and its corresponding output given below to better understand how this function should work and the format of the warning message) For this function, you MUST use the following header This function takes a list of employees together with the name, phone number and room number of employee to be added. If the does not exist in the list, the function adds a tuple for the enployee to the end of the list. Otherwise, if the name already exists in the list, the function does not add 1 ay tuple to the list and displays a warning sage (for the age format, see the output example of the test progran given below). You may assume that the arguments are always walld. That the same and the room ber are always stringa and the ploce number is always a positive integer. def add_employee (employee_list, sane, phone, roos): write your code here REMOVE AN EMPLOYEE This function removes an employee from the office directory. The employee name is specified as a parameter. If there is no employee with the specified name, the function does not remove any employee from the office directory and displays a warning message. Otherwise, it performs the action. (See the example test program and its corresponding output given below to better understand how this function should work and the format of the warning message) For this function, you MUST use the following header This function takes list of employees together with the name of an employee to be removed. If the mane exists in the list, the fonotion removes the corresponding tuple from the list. Otherwise, I then does not exist in the list, the function does not remove any tuple from the list and displays a warning message for the message format, see the outpat example of the test program gives below. You may that the same argument is always & string def remove_employee (employee_list, nane): Write your code here DISPLAY ALL EMPLOYEES This function lists all employees already found in the office directory. The output should be in the following format. If there are no employees in the directory, this function displays --EMPTY-(See the output example of the test program given below to better understand the format. Nane, office number, roon number for the Ist employee) Blane, office number, roon number for the and employee For this function, you MUST use the following header This function takes a list of employees and displays all employee tuples found the list according to the required output format. If there exist . tuples the list, this functie displays --TY-- (e the output example of the test program given below) det display_all(onployec_list): Write your code bere SHOW AN EMPLOYEE This function displays all information about an employee whose name is specified as a parameter. The output should be in the following format. If the employee with the specified name does not exist in the office directory, the function displays a warning message. See the example test program and its corresponding output given below to better understand how this function should work and the format of the warning message) Nane: name of the employee Office: room number of the employee Tel: phone number of the employee For this function, you MUST use the following header This function takes a list of employees together with the name of an employee whose information will be showed. If the name exists in the list, the function - diaplays the informatioe stored in the corresponding tople according to the required output format. If the name does not exist in the list, it displays Ha varsing sage (for the sage format, see the output example of the test program given below. You may are that the name argument is always a string de show_employee (employee_list, name): Write your code here WHAT TO SUBMIT? Unlike the previous ones, this homework assignment asks you to submit only one file whose name must be office.py. This file should contain at least four functions whose details are given above. Remember that the headers of these functions must be def add_employee employee_list, sane, phone, roos): de remove_employee (employee_list, hane): def display_all(employee_list): det show_employee (employee_list, name) Your file may contain other auxiliary functions, which might be called from the aforementioned four functions. However, it SHOULD NOT contain a function whose name is main(). Additionally, this file SHOULD NOT have any statements written outside a function definition. We wil test your functions writing our own main function, similar to the one given below, and caling this main function to start the program ***IMPORTANT: You MUST use the given function headers as they are. We will use these headers to call your functions and test them. You are NOT allowed to modify these function headers. If you modify them, you will get no points from the corresponding part since we cannot call your functions properly, and thus, we cannot test and grade them. Additionally, if your file contains a function called main() or if it has a statement outside any function definition, you may lose a considerable number of points. Note that although you will not submit a main function, you should, of course, write a main function in another py file and test your own functions but do not submit this additional py file). Like the previous homework assignments, the correctness of your program will affect your grade. However, in addition to this, the following points are important to get full credit You MUST use meaningful names for the variables. . - You MUST write explanatory and clearly understandable comments - At the beginning of each file, you MUST write your name your id, and your section as , , comments. After these, you MUST provide a very brief description about what the program does as additional comments For this assignment, you are allowed to use the codes given in the recommended textbooks and/or our lecture slides. However, you ARE NOT ALLOWED to use any codes from other sources (including the codes given in other textbooks, found on the Internet, belonging to your dassmates, etc.). Do not forget that plagiarism and cheating will be heavily punished. Please do the homework yourself. Before submitting your homework, please be sure that you carefully read all these explanations and understood them very well. Here is an example test program, containing an example main function, and the corresponding output. We will use a similar program to test your functions so make sure that the name of your submitted file is office.py and you use the functions headers given above. import office def main) 11 office.display_all() print('------- office add_employee. 'Cigden Gunduz', 1953, ENIM office.add_exployees, Serkas cil', , 'GRE 02 office add employee. Mehmet SAYAR, 2222, ENG118) office.add employee E. Seher Ozcelik, 3333, ENG123 office add_crployee, 'ulken Kasapogle, 3333, XC:23) office.display ail) print office add_employee (L. CI den Gunduz', 4444, SKA 52 office.add_employee Seher Ozcelk, ssss, sos 37 print > office.display_alli) printi'--------------- office.ahew_exployees. 'Cigden GUNDUE"> printr- office.show_employee L. 'Uiken Kasapoglu printi --------- office show employee, Mehmet Sayar) print) office show employee, Merve BUSAK) , print office.remove employee, Mat Sayar office.display_all) print!'' office.ahew_exployee, het Sayar print office.remove_employees. 'Merve BUNAK) print(' ' office.cenove_employee, Cigden Gundus office.remove_exployeeSeber Ozcelik office.zoneve_ployees. 'ulken sataposle office.display all print office.remove_employee (L. Serkam chi office.display all) print 2 main) The output of this test program should be: ins .2222 --EMPTY Cigden Gundus, ENG108 1853 Serkan CA1 GRT 02 Mehmet SAYA, ENGILIA Seher Oncelik, YNG123 3333 ulkon Kasapoglu . ING123.3333 [error in add) CIGden Gunduz already exista [Bror in add Saber Cecelik already exista Cigden Gundur,NG108, 1853 Berkan cil CART 02 1111 Mehmet SAYAR, ENG1181, 2222 Beher Ozcelik, INC.23, 3333 ulkan Kasapoglu, INC.23, 3333 Name: Cigden Cunduse Office: ENCOBA Tel. 1853 Name: Viken kasapoglu Office ENG123 Tel: 3333 Name: Mehmet SAYA Office: ENCIL Tel. 2222 (error in show) Merve KUNAK is not found Cigden Cundus INCLOSA, 1853 Serkan Cil, RT 02, 1111 Seher Cecelik ENCL23 3333 ulken Kasapoglu , INC.23, 3333 [error in ahon) Mat Sayar is not found [error in remove) Merve KUNAK is not found Serkan Cil, GRT 02.1111 --ENTY

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Describe Hobbess position on epistemology.

Answered: 1 week ago