Question 1
# created a list of elements named list
list = [2, 4, 6, 8, 10, 12, 14, 0]
# i called the index of the third item in the list, and put it into a variable called ind
ind = list[3]
# i multiplied the varible 'ind' by 2 and set ind as the new value
ind *= 2
# i added the variable ind to the list as the 7th element
list[7] = ind
# printed the new list
print(list)
[2, 4, 6, 8, 10, 12, 14, 16]
Question 2
import math
def iterations(length):
return math.ceil(math.log2(length))
worstcase = iterations(20)
print(worstcase)
5
Question 3
The result of the function would be A. [20, 40, 60, 80, 100]. The function goes through eache element in the list and multiplies it by 2. after multiplying each by 2, the final answer will be A.