Question 1:
def findthrees(list):
sum=0
for x in range(0,len(list)):
if(list[x]%3==0):
sum+=list[x]
return(sum)
list=[0,4,2,6,9,8,3,12]
print(“The list is: “,list)
print(“The sum of the numbers of the list divisible by three is: “,findthrees(list))
Question 2:
def dotproduct(x,y):
ab=[]
for i in range(0,len(x)):
ab.append(x[i]*y[i])
return sum(ab)
v1=[2,4,5,6]
v2=[1,2,3,4]
total=dotproduct(v1,v2)
print (“The dot product of this two vector is: “,total)
#QUIZ10 #TC1014 by Luis Vargas is licensed under a Creative Commons Attribution 4.0 International License.