What would be the output of the following code? If there is…
What would be the output of the following code? If there is an error, write “ERROR” def modify_data(data): value = data.get(‘x’, 0) + data.get(‘y’, 0) data.clear() data[‘result’] = value return data.get(‘z’, ‘Not found’)numbers = {‘x’: 3, ‘y’: 7, ‘z’: 5}print(modify_data(numbers))
Read Details7.5 points The following code is meant to calculate the ave…
7.5 points The following code is meant to calculate the average salary of employees, but it contains errors. Identify the line numbers that would raise exceptions when executed. 1. employees = { ‘Alice’: (28, 5000), ‘Bob’: (34, 6000), ‘Clara’: (25, 4500)}2. departments = {‘HR’, ‘IT’, ‘Design’}3. employees[‘Bob’][1] = 6200 4. departments.add([‘Finance’, ‘Admin’]) 5. employees.add((‘David’, (30, 5500))) 6. first_dept = departments[0] 7. total = 08. for person in employees:9. total += employees[person][1]10. average = total / len(employees)11. print(“Average salary:”, average)
Read Details