What would be the output of the following code? If there is an error, write “ERROR” numbers = [8, 15, 22, 9, 31]total = 0for n in numbers: if n > 10: if n % 2 == 1: total += 5 else: total -= 2 else: if n >= 8: total += n else: total -= 4print(total)
Blog
OnlineGDB: LINK Online Python: LINKWrite a function called d…
OnlineGDB: LINK Online Python: LINKWrite a function called department_budget that takes a nested dictionary representing company departments and their employees with salaries, and returns a dictionary showing the total budget (sum of all salaries) for each department. Inputs: company: a dictionary where: Keys are department names (strings) Values are lists of dictionaries, where each dictionary represents one employee with keys “name” (employee name) and “salary” (integer) Output: A dictionary where: Keys are department names (strings) Values are the total salary budget for that department (integer) Departments with no employees should have a budget of 0 Example 1: company = { “Engineering”: [ {“name”: “Alice”, “salary”: 90000}, {“name”: “Bob”, “salary”: 85000}, {“name”: “Charlie”, “salary”: 95000} ], “Sales”: [ {“name”: “Diana”, “salary”: 70000}, {“name”: “Eve”, “salary”: 75000} ], “HR”: [ {“name”: “Frank”, “salary”: 60000} ], “Marketing”: []}print(department_budget(company))# Expected output: {‘Engineering’: 270000, ‘Sales’: 145000, ‘HR’: 60000, ‘Marketing’: 0} Example 2: company2 = { “IT”: [ {“name”: “John”, “salary”: 80000}, {“name”: “Jane”, “salary”: 82000} ], “Finance”: [ {“name”: “Mike”, “salary”: 95000} ]}print(department_budget(company2)) # Expected output: {‘IT’: 162000, ‘Finance’: 95000}print(department_budget({})) # Expected output: {}
What would be the output of the following code? cities = {…
What would be the output of the following code? cities = { “Tokyo”: 37, “Delhi”: 31, “Shanghai”: 28}cities[“Mumbai”] = 21del cities[“Shanghai”]print(len(cities), “Tokio” in cities, cities.get(“Shanghai”, 0))
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 transform_list(nums, depth): if depth == 0: return nums else: new_nums = [nums[i] * (i + 1) for i in range(len(nums))] return transform_list(new_nums, depth – 1)result = transform_list([2, 3, 1], 3)print(sum(result))
What would be the output of the following code? def modify_…
What would be the output of the following code? 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))
Sometimes our emotional responses such as simple likes or di…
Sometimes our emotional responses such as simple likes or dislikes occur quickly. These emotional reactions follow a neural pathway from the _____ to the ______.
The kids in Anna’s neighborhood deliberately ignore her, and…
The kids in Anna’s neighborhood deliberately ignore her, and they never ask her to join them in any of their outdoor activities. Their treatment of Anna most clearly illustrates
Which of these is NOT an ability associated with emotional i…
Which of these is NOT an ability associated with emotional intelligence?
Two of the five components that Sternberg associated with cr…
Two of the five components that Sternberg associated with creativity were
The inability to see a problem from a new perspective is cal…
The inability to see a problem from a new perspective is called