/
quiz08.py
52 lines (38 loc) · 994 Bytes
/
quiz08.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
def vectorial (x,y):
lx = len(x)
ly = len(y)
if (ly != lx):
r = "NaN"
return (r)
else:
n = 0
r = 0
while ( n != lx):
r = r + (x[n]*y[n])
n = n+1
return (r)
#Two blank list
x=[]
y=[]
#In a real program, x and y would be lists given by the user
c = "y"
while (c == "y"):
z = input ("Give me an integer for the FIRST set: ")
x.append(z)
c = input("Do you want to add more numbers to the set? Answer y for yes: ")
c = c.lower()
c = "y"
while (c == "y"):
z = input ("Give me an integer for the SECOND set: ")
y.append(z)
c = input("Do you want to add more numbers to the set? Answer y for yes: ")
c = c.lower()
#Converts all members of the list to integers
l = len(x)
for e in range (0,l):
x[e] = int(x[e])
y[e] = int(y[e])
t = vectorial(x,y)
print ("The first list is: ",x)
print ("The second list is: "y)
print ("The result is: ", t)