Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Print answers with one decimal place, for example 1.0 or 2.0 instead of 1 or 2, below code only prints answers as integers. Write a
Print answers with one decimal place, for example 1.0 or 2.0 instead of 1 or 2, below code only prints answers as integers.
Write a python program to input two vectors and compute and print their inner product as follows: given v1=(x1,71,z1) and v2=(x2,y2,22), inner_product(v1,v2)=x1 * x2 + y1 * y2 +21 * 22. Input each vector using a single input statement (details in template), e.g. enter x1, yl, z1 :: 1,2,3 enter x2, y2, 22 :: 4,5,6 output a single line formatted to print the two input vectors and the inner product value. e.g.: inner product of vl=[1.0, 2.0, 3.0], v2=[4.0, 5.0, 6.0] is 32.0 what data structure is best suited to store each vector? why? note that for computing the inner product, python's numpy package can be used: import numpy inner_product=numpy.inner (v1,v2) print (inner_product) we will see more of numpy in later sections... 354942.2346220.qx3zqy7 LAB ACTIVITY 3.21.1: Vector inner product 0/2 main.py Load default template... 1 import numpy 2 v1=eval(input("enter x1, y1, z1 :: ")) 3 v2=eval(input("enter x2,y2,z2 :: ")) 4 vArr1=numpy.array(v1) 5 VArr2=numpy.array(v2) 6 inner_product=numpy.inner(v1, v2) 7 print("inner product of v1 = ", VArr1,", v2 = ", Arr2," is ", inner_product)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started