Question: python please; 1a.) Write a function called double_list(nums) that takes in a list of integers as an argument and returns a new list where each

python please;

1a.) Write a function called double_list(nums) that takes in a list of integers as an argument and returns a new list where each integer is multiplied by 2. You should use a for loop and the append() method to construct the new list.

Test case:

nums = [1, 2, 3, 4, 5] result = double_list(nums) print(result) # Output: [2, 4, 6, 8, 10]

1b.) Write a function called sum_concat(my_dictionary) that takes in a dictionary my_dictionary as an argument and returns a tuple containing the sum of all the values in the dictionary and the concatenation of all the keys in the dictionary as a string. Use the .items() method to iterate through the key-value pairs of the dictionary.

Test case:

my_dict = {'a':1, 'b':2, 'c':3} result = sum_concat(my_dict) print(result) # Output: (6, 'abc')

1c.)

Write a function called reverse_queue(queue) that takes in a queue as an argument and modifies the queue so that its elements are in reverse order. You should use a stack data structure to reverse the order of the elements.

Test case:

from collections import deque queue = deque(["a", "b", "c", "d"]) reverse_queue(queue) print(queue) # Output: deque(["d", "c", "b", "a"])

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!