I'm having some trouble hard coding the inner product calculations using Python and could use some assistance.
Right now, here is my code:
def getNums(): one = [] Strx = input("Enter a number (<Enter> to quit) >> ") while Strx != "": x = float(Strx) one.append(x) Strx = input("Enters some numbers. Press Enter to quit") return one def innerproduct(one): total = 0 for index, val in enumerate(one): if index % 2 == 0: total *= val else: total += val return total
I'm assuming this is incorrect to get my values, but can someone lead me in the right direction so I can get the inner product? I'm trying to calculate by using x1 * b1 + x2 * b2 + x3 * b3... etc.
https://stackoverflow.com/questions/67238658/how-to-hard-code-inner-product-using-python April 24, 2021 at 09:51AM
没有评论:
发表评论