# Program to read two vectors of dimension n and determine the sum and dot product of them:
n=input("Enter the number of dimension:")
n=int(n)
x=[]
y=[]
z=[]
t=0
for i in range(1,n+1):
s=input("Enter the component "+str(i)+" of the first vector:")
s=float(s)
x.append(s)
for i in range(1,n+1):
d=input("Enter the component "+str(i)+" of the second vector:")
d=float(d)
y.append(d)
for i in range(0,n):
c=x[i]+y[i]
z.append(c)
for i in range(0,n):
p=x[i]*y[i]
t=t+p
print("The sum of the entered vectors are:",z)
print("The dot product of the entered vectors are:",t)
n=input("Enter the number of dimension:")
n=int(n)
x=[]
y=[]
z=[]
t=0
for i in range(1,n+1):
s=input("Enter the component "+str(i)+" of the first vector:")
s=float(s)
x.append(s)
for i in range(1,n+1):
d=input("Enter the component "+str(i)+" of the second vector:")
d=float(d)
y.append(d)
for i in range(0,n):
c=x[i]+y[i]
z.append(c)
for i in range(0,n):
p=x[i]*y[i]
t=t+p
print("The sum of the entered vectors are:",z)
print("The dot product of the entered vectors are:",t)
Comments
Post a Comment