Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using the following two lists, write functional Python code (each question shoul

ID: 671692 • Letter: U

Question

Using the following two lists, write functional Python code (each question should be completed in one line of Python to:

list1 = [1, 2, 3, 4, 5]

list2 = [6, 7, 8, 9, 10]

a) Multiply the elements in the same positions within list1 and list2 together(hint: resulting list should be equal [6, 14, 24, 36, 50])

b) Multiply the elements in list1 together then multiply that value by the sum of the contents of list2 (resulting product should be 4800).

c) Convert the elements of list1 from integers to strings.

d) Filter the concatenated lists (list1 and list2) by even values (resulting list should be [2, 4, 6, 8, 10]).

Explanation / Answer

list1 = [1, 2, 3, 4, 5]
list2 = [6, 7, 8, 9, 10]
list3 = [a*b for a,b in zip(list1,list2)]
print list3

result = reduce(lambda x, y: x*y, list1)*sum(list2)
print result

list1 = [str(item) for item in list1]
print list1

list1 = [1, 2, 3, 4, 5]
list2 = [6, 7, 8, 9, 10]

evenList = [item for item in list1+list2 if item%2 == 0]
print evenList